]> arthur.barton.de Git - ax-zsh.git/commitdiff
axzshctl: Implement "--help" option, and ehnance error handling
authorAlexander Barton <alex@barton.de>
Tue, 31 Dec 2019 15:56:50 +0000 (16:56 +0100)
committerAlexander Barton <alex@barton.de>
Tue, 31 Dec 2019 15:56:50 +0000 (16:56 +0100)
Don't exit with an error code ("non-null") when the usage information
was requested with "--help", and write errors parsing the command line
to stderr and exit with code 2.

bin/axzshctl

index 0c4da38f492caf61cc8959e18f5323de70a6a737..1c41425990e0fb4091d6a2a5bd43a1a97fb5cb9c 100755 (executable)
@@ -51,7 +51,7 @@ function Usage {
        echo "  update-caches"
        echo "    Force rebuild of all cache files."
        echo
-       exit 2
+       exit 0
 }
 
 function UpdatePluginCache {
@@ -401,6 +401,11 @@ case "$cmd" in
                [[ $# -eq 0 ]] || Usage
                UpdatePluginCache
                ;;
-       *)
+       "--help")
                Usage
+               ;;
+       *)
+               ax_error "Invalid command \"$cmd\"!"
+               ax_error "Try \"$0 --help\" for more information."
+               exit 2
 esac