diff options
| author | Julian Hurst <julian.hurst@digdash.com> | 2025-01-23 15:23:08 +0100 |
|---|---|---|
| committer | Julian Hurst <julian.hurst@digdash.com> | 2025-01-23 15:23:08 +0100 |
| commit | ea7aef4d9e79bf35d6968f2d370f6f67271d3e73 (patch) | |
| tree | 428190c83945b81a2a0a2ac03d7b6f7fbd130809 | |
| parent | 13be6af305a69e58821d79a1ecbd64199a8981c4 (diff) | |
| download | box-ea7aef4d9e79bf35d6968f2d370f6f67271d3e73.tar.gz | |
Get token from stdin instead of flag
| -rw-r--r-- | main.go | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -11,6 +11,7 @@ import ( "path" "path/filepath" "flag" + "bufio" "github.com/google/uuid" ) @@ -114,13 +115,22 @@ func (handler BoxHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func main() { host := flag.String("n", "", "The hostname to listen on") port := flag.Int("p", 8080, "The port to listen on") - token := flag.String("t", "", "The token to use to protect uploads") + isToken := flag.Bool("t", false, "Use a token to protect uploads/deletes") filesPath := flag.String("d", "", "The path to the files") deleteEnabled := flag.Bool("D", false, "Enable deleting resources") flag.Parse() + + token := "" + if *isToken { + fmt.Print("Token: ") + sc := bufio.NewScanner(os.Stdin) + sc.Scan() + token = sc.Text() + } + boxHandler := BoxHandler { *filesPath, - *token, + token, *deleteEnabled, } if boxHandler.filesPath != "" { |
