1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package main
import (
"flag"
"fmt"
"log"
"os"
)
var host = ""
var port = GeminiPort
func usage() {
fmt.Printf("Usage: %s [options] url\n", os.Args[0])
flag.PrintDefaults()
}
func main() {
flag.Usage = usage
flag.StringVar(&host, "h", host, "server host name")
flag.StringVar(&host, "host", host, "server host name")
flag.IntVar(&port, "p", port, "server port number")
flag.IntVar(&port, "port", port, "server port number")
flag.Parse()
if flag.NArg() != 1 {
fmt.Printf("Got %d arguments, expected 1\n", flag.NArg())
flag.Usage()
os.Exit(1)
}
conn, err := NewGeminiConn(flag.Arg(0), port)
if err != nil {
log.Fatalf("Error parsing hostname: %s\n", err.Error())
}
log.Printf("connecting to: %s\n", conn.host)
err = conn.Get(FormatRequest(flag.Arg(0)), os.Stdout)
if err != nil {
log.Fatalf("Error: %s\n", err.Error())
}
}
|