aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go20
1 files changed, 15 insertions, 5 deletions
diff --git a/main.go b/main.go
index a4c2190..f5d241c 100644
--- a/main.go
+++ b/main.go
@@ -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)