main: friendlier error message on wrong number of arguments
Before: Usage: gocryptfs [OPTIONS] CIPHERDIR MOUNTPOINT After: Wrong number of arguments (have 9, want 2). You passed: "-nosyslog" "." "asd" "-q" "ß" "asdf" "fg" "gh" "sdf" "asd fs\\dfg" Usage: gocryptfs [OPTIONS] CIPHERDIR MOUNTPOINT
This commit is contained in:
parent
d3b78fea95
commit
495479dc66
11
main.go
11
main.go
@ -214,6 +214,15 @@ func main() {
|
||||
}
|
||||
changePassword(&args) // does not return
|
||||
}
|
||||
// Mount
|
||||
// Default operation: mount.
|
||||
if flagSet.NArg() != 2 {
|
||||
prettyArgs := fmt.Sprintf("%q", os.Args[1:])
|
||||
// Get rid of "[" and "]"
|
||||
prettyArgs = prettyArgs[1 : len(prettyArgs)-1]
|
||||
tlog.Info.Printf("Wrong number of arguments (have %d, want 2). You passed: %s",
|
||||
flagSet.NArg(), prettyArgs)
|
||||
tlog.Fatal.Printf("Usage: %s [OPTIONS] CIPHERDIR MOUNTPOINT", tlog.ProgramName)
|
||||
os.Exit(ErrExitUsage)
|
||||
}
|
||||
os.Exit(doMount(&args))
|
||||
}
|
||||
|
4
mount.go
4
mount.go
@ -26,10 +26,6 @@ import (
|
||||
// Called from main.
|
||||
func doMount(args *argContainer) int {
|
||||
// Check mountpoint
|
||||
if flagSet.NArg() != 2 {
|
||||
tlog.Fatal.Printf("Usage: %s [OPTIONS] CIPHERDIR MOUNTPOINT", tlog.ProgramName)
|
||||
os.Exit(ErrExitUsage)
|
||||
}
|
||||
var err error
|
||||
args.mountpoint, err = filepath.Abs(flagSet.Arg(1))
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user