diff --git a/cmd/restray/cli.go b/cmd/restray/cli.go index 79173eb..2a54c81 100644 --- a/cmd/restray/cli.go +++ b/cmd/restray/cli.go @@ -16,7 +16,7 @@ func cliUsage() { fmt.Fprintf(os.Stderr, `Usage: restray [command] Commands: - (no command) Launch GUI + (no command) Launch GUI with built-in scheduler schedule [-p name] Run full schedule with hooks op|operation backup [-p name] Run backup op prune [-p name] Prune old snapshots diff --git a/cmd/restray/main.go b/cmd/restray/main.go index cdba136..5caab73 100644 --- a/cmd/restray/main.go +++ b/cmd/restray/main.go @@ -1,6 +1,7 @@ package main import ( + "io" "log" "os" @@ -11,6 +12,11 @@ import ( const version = "0.10.0" func main() { + verbose := len(os.Args) > 1 && (os.Args[1] == "-v" || os.Args[1] == "--verbose") + if verbose { + os.Args = append(os.Args[:1], os.Args[2:]...) + } + if len(os.Args) > 1 { os.Exit(runCLI(os.Args[1:])) } @@ -25,7 +31,11 @@ func main() { f, err := os.OpenFile(logPath(), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0600) if err == nil { - log.SetOutput(f) + if verbose { + log.SetOutput(io.MultiWriter(f, os.Stderr)) + } else { + log.SetOutput(f) + } log.SetFlags(log.Ldate | log.Ltime) }