summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Hurst <julian.hurst@digdash.com>2025-01-23 15:23:08 +0100
committerJulian Hurst <julian.hurst@digdash.com>2025-01-23 15:23:08 +0100
commitea7aef4d9e79bf35d6968f2d370f6f67271d3e73 (patch)
tree428190c83945b81a2a0a2ac03d7b6f7fbd130809
parent13be6af305a69e58821d79a1ecbd64199a8981c4 (diff)
downloadbox-ea7aef4d9e79bf35d6968f2d370f6f67271d3e73.tar.gz
Get token from stdin instead of flag
-rw-r--r--main.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.go b/main.go
index 56445a9..3c8b1a5 100644
--- a/main.go
+++ b/main.go
@@ -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 != "" {