diff --git a/main.go b/main.go index a7243be..8985b84 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "flag" "fmt" "os" "os/exec" @@ -42,6 +43,9 @@ func main() { fmt.Println("#################################################") fmt.Println() + uploadMissing := flag.Bool("upload-missing", os.Getenv("DS_CC_UPLOAD_MISSING") == "true", "true, to upload files to docspell that do not yet exist there") + flag.Parse() + // Read config from user profile homeDir, err := os.UserHomeDir() if err != nil { @@ -86,8 +90,7 @@ func main() { } fmt.Println("Settings:") - uploadMissing := os.Getenv("DS_CC_UPLOAD_MISSING") == "true" - if uploadMissing { + if *uploadMissing { fmt.Println(" - UPLOAD files? YES") fmt.Println(" files not existing in Docspell will be uploaded and will be re-checked in the next run.") } else { @@ -137,7 +140,7 @@ func main() { } } else { fmt.Println("Files does not exist, yet") - if uploadMissing { + if *uploadMissing { fmt.Print("...uploading file..") cmd = exec.Command("dsc", "-f", "json", "upload", path) output, err := cmd.Output()