aboutsummaryrefslogtreecommitdiff
path: root/cmd/send-over-http/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/send-over-http/main.go')
-rw-r--r--cmd/send-over-http/main.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/cmd/send-over-http/main.go b/cmd/send-over-http/main.go
index 3c587ff..4bd9750 100644
--- a/cmd/send-over-http/main.go
+++ b/cmd/send-over-http/main.go
@@ -17,27 +17,34 @@ func exitOnErr(err error) {
}
func usage() {
- fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s [target]\n", os.Args[0])
+ fmt.Fprintf(flag.CommandLine.Output(), "Usage %s <options> [target]\n", os.Args[0])
fmt.Fprintln(flag.CommandLine.Output())
- fmt.Fprintf(flag.CommandLine.Output(), "\ttarget - file or directory to share (default: .)\n")
+ fmt.Fprintf(flag.CommandLine.Output(), " target: file or directory to share (default: .)\n")
+ fmt.Fprintln(flag.CommandLine.Output())
+ fmt.Fprintln(flag.CommandLine.Output(), "Options:")
+ fmt.Fprintln(flag.CommandLine.Output())
+ flag.PrintDefaults()
fmt.Fprintln(flag.CommandLine.Output())
}
func main() {
+ config := sendoverhttp.Config{}
+
+ flag.StringVar(&config.Network, "net", "tcp", "network type to listen on (tcp, tcp4, tcp6)")
+ flag.StringVar(&config.ListenAddress, "address", "", "network address to accept connections (example: 127.0.0.1:1234)")
flag.Usage = usage
flag.Parse()
- var fp string
if len(os.Args) == 2 {
- fp = os.Args[1]
+ config.FilePath = os.Args[1]
}
- if fp == "" {
+ if config.FilePath == "" {
v, err := os.Getwd()
exitOnErr(err)
- fp = v
+ config.FilePath = v
}
- s := sendoverhttp.NewServer(fp)
+ s := sendoverhttp.NewServer(config)
go s.Start()
time.Sleep(250 * time.Millisecond)