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.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/send-over-http/main.go b/cmd/send-over-http/main.go
new file mode 100644
index 0000000..3c587ff
--- /dev/null
+++ b/cmd/send-over-http/main.go
@@ -0,0 +1,48 @@
+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()
+}