package main import ( "flag" "fmt" "os" "time" sendoverhttp "git.server.ky/cypher/send-over-http" ) func exitOnErr(err error) { if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(-1) } } func usage() { fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s [target]\n", os.Args[0]) fmt.Fprintln(flag.CommandLine.Output()) fmt.Fprintf(flag.CommandLine.Output(), "\ttarget - file or directory to share (default: .)\n") fmt.Fprintln(flag.CommandLine.Output()) } func main() { flag.Usage = usage flag.Parse() var fp string if len(os.Args) == 2 { fp = os.Args[1] } if fp == "" { v, err := os.Getwd() exitOnErr(err) fp = v } s := sendoverhttp.NewServer(fp) go s.Start() time.Sleep(250 * time.Millisecond) fmt.Println("press enter to exit") _, _ = fmt.Scanln() s.Stop() }