feat: use flag to enable upload
fallback to env var is kept
This commit is contained in:
parent
a8c452d246
commit
cfa8c7e9f9
9
main.go
9
main.go
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -42,6 +43,9 @@ func main() {
|
|||||||
fmt.Println("#################################################")
|
fmt.Println("#################################################")
|
||||||
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
|
// Read config from user profile
|
||||||
homeDir, err := os.UserHomeDir()
|
homeDir, err := os.UserHomeDir()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -86,8 +90,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Settings:")
|
fmt.Println("Settings:")
|
||||||
uploadMissing := os.Getenv("DS_CC_UPLOAD_MISSING") == "true"
|
if *uploadMissing {
|
||||||
if uploadMissing {
|
|
||||||
fmt.Println(" - UPLOAD files? YES")
|
fmt.Println(" - UPLOAD files? YES")
|
||||||
fmt.Println(" files not existing in Docspell will be uploaded and will be re-checked in the next run.")
|
fmt.Println(" files not existing in Docspell will be uploaded and will be re-checked in the next run.")
|
||||||
} else {
|
} else {
|
||||||
@ -137,7 +140,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Files does not exist, yet")
|
fmt.Println("Files does not exist, yet")
|
||||||
if uploadMissing {
|
if *uploadMissing {
|
||||||
fmt.Print("...uploading file..")
|
fmt.Print("...uploading file..")
|
||||||
cmd = exec.Command("dsc", "-f", "json", "upload", path)
|
cmd = exec.Command("dsc", "-f", "json", "upload", path)
|
||||||
output, err := cmd.Output()
|
output, err := cmd.Output()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user