diff --git a/bin/frama-c-script b/bin/frama-c-script index e3dafca01d88506b4c9402155b7c5b0f84f1b29e..17c2872620774db6c5d46115422e0ecc2b12542f 100755 --- a/bin/frama-c-script +++ b/bin/frama-c-script @@ -26,11 +26,14 @@ while [ $# -ge 1 -a "$1" = "-check" ]; do shift done -if [ $# -lt 1 ]; then +usage() { echo "usage: $0 cmd [args]" echo "" echo " where cmd is:" echo "" + echo " - help" + echo " Display this help message and exit." + echo "" echo " - make-template [dir]" echo " Interactively prepares a template for running analysis scripts," echo " writing it to [dir/GNUmakefile]. [dir] is [.] if omitted." @@ -74,7 +77,11 @@ if [ $# -lt 1 ]; then echo " - normalize-jcdb [path/to/compile_commands.json]" echo " Applies some transformations to an existing compile_commands.json" echo " (such as relativizing paths) to improve portability" - exit + exit $1 +} + +if [ $# -lt 1 ]; then + usage 1 fi DIR="$( cd "$( dirname "$0" )" && pwd )" @@ -276,6 +283,9 @@ normalize_jcdb() { } case "$command" in + "help" | "-help" | "--help" | "-h") + usage 0; + ;; "make-template") shift; make_template "$@"; @@ -313,5 +323,6 @@ case "$command" in normalize_jcdb "$@"; ;; *) - echo "error: unrecognized command: $command" + echo "error: unrecognized command: $command"; + exit 1 esac