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()) } }