aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-11-15 20:30:21 +0100
committerJakob Unterwurzacher2017-11-15 20:30:21 +0100
commit1b0426bcb23a1850f3a03619a15413281dc733e3 (patch)
tree6b809a40dd833f5b7b699bfb98cc7cc639b7d433 /main.go
parente36a0ebf189a826aaa63909c5518c16356f5f903 (diff)
main: print clear error message if CIPHERDIR is missing
Getting just the help text in response to gocryptfs -info -config external.config is confusing: https://github.com/rfjakob/gocryptfs/issues/157
Diffstat (limited to 'main.go')
-rw-r--r--main.go25
1 files changed, 16 insertions, 9 deletions
diff --git a/main.go b/main.go
index f790fff..f10adfb 100644
--- a/main.go
+++ b/main.go
@@ -143,18 +143,25 @@ func main() {
tlog.Warn.Wpanic = true
tlog.Debug.Printf("Panicing on warnings")
}
- // Every operation below requires CIPHERDIR. Check that we have it.
- if flagSet.NArg() >= 1 {
- args.cipherdir, _ = filepath.Abs(flagSet.Arg(0))
- err = checkDir(args.cipherdir)
- if err != nil {
- tlog.Fatal.Printf("Invalid cipherdir: %v", err)
- os.Exit(exitcodes.CipherDir)
+ // Every operation below requires CIPHERDIR. Exit if we don't have it.
+ if flagSet.NArg() == 0 {
+ if flagSet.NFlag() == 0 {
+ // Naked call to "gocryptfs". Just print the help text.
+ helpShort()
+ } else {
+ // The user has passed some flags, but CIPHERDIR is missing. State
+ // what is wrong.
+ tlog.Fatal.Printf("CIPHERDIR argument is missing")
}
- } else {
- helpShort()
os.Exit(exitcodes.Usage)
}
+ // Check that CIPHERDIR exists
+ args.cipherdir, _ = filepath.Abs(flagSet.Arg(0))
+ err = checkDir(args.cipherdir)
+ if err != nil {
+ tlog.Fatal.Printf("Invalid cipherdir: %v", err)
+ os.Exit(exitcodes.CipherDir)
+ }
// "-q"
if args.quiet {
tlog.Info.Enabled = false