From 4104c2f934c07e90cfabf7762d22656a31054229 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Mon, 4 Jan 2021 10:16:10 -0500 Subject: [PATCH] Exit with code 2 when an invalid command is provided --- duplicacy/duplicacy_main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/duplicacy/duplicacy_main.go b/duplicacy/duplicacy_main.go index aa754c98..9fe4ce0d 100644 --- a/duplicacy/duplicacy_main.go +++ b/duplicacy/duplicacy_main.go @@ -2188,6 +2188,12 @@ func main() { app.Usage = "A new generation cloud backup tool based on lock-free deduplication" app.Version = "2.7.2" + " (" + GitCommit + ")" + // Exit with code 2 if an invalid command is provided + app.CommandNotFound = func(context *cli.Context, command string) { + fmt.Fprintf(context.App.Writer, "Invalid command: %s\n", command) + os.Exit(2) + } + // If the program is interrupted, call the RunAtError function. c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt)