From 64a4e41b8b4a21b7609e8f4f6aad82c4e829adf4 Mon Sep 17 00:00:00 2001 From: PrivateGER Date: Sun, 17 Oct 2021 00:21:37 +0200 Subject: [PATCH] Add -path argument --- main.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 39a5c08..bbff073 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( _ "embed" + "flag" "fmt" "net/http" "os" @@ -11,10 +12,10 @@ import ( ) func main() { - path := os.Getenv("directory") - if path == "" { - path = "/home/latte/NFS/MainArchive/" - } + var path string + flag.StringVar(&path, "path", "./", "the full path to the ytdlp archive (with a / suffix)") + + flag.Parse() var FL DirectoryIndexers.FileList go func() { @@ -29,13 +30,6 @@ func main() { } }() - /*FL.RLock() - fmt.Println(strconv.Itoa(len(FL.Files))) - for _, file := range FL.Files { - fmt.Println("Name:", file.Title,"Extension:", file.Extension, "ID:", file.Id) - } - FL.RUnlock()*/ - http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { fmt.Println(time.Now().String(),request.URL) PageHandlers.Index(writer, request, &FL)