diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -16,16 +16,19 @@ func main() { flags := struct { host string port int + input string output string }{ host: "", port: GeminiPort, + input: "", output: "", } flag.Usage = usage - flag.StringVar(&flags.host, "h", flags.host, "server host name") - flag.IntVar(&flags.port, "p", flags.port, "server port number") + flag.StringVar(&flags.host, "host", flags.host, "server host name") + flag.IntVar(&flags.port, "port", flags.port, "server port number") + flag.StringVar(&flags.input, "i", flags.input, "read urls from file") flag.StringVar(&flags.output, "o", flags.output, "write output to path") flag.Parse() if flag.NArg() != 1 { @@ -34,9 +37,16 @@ func main() { os.Exit(1) } - conn, err := NewGeminiConn(flag.Arg(0), flags.port) - if err != nil { - log.Fatalf("Error parsing hostname: %s\n", err.Error()) + var conn *GeminiConn + var err error + + if flags.host != "" { + conn = NewGeminiConn(flags.host, flags.port) + } else { + conn, err = NewGeminiConnFromRequest(flag.Arg(0), flags.port) + if err != nil { + log.Fatalf("Error parsing hostname: %s\n", err.Error()) + } } log.Printf("connecting to: %s\n", conn.host) |