Improve handling of options allowed for "lb" before the sub-command

This commit is contained in:
Raphaël Hertzog 2020-04-24 16:00:05 +02:00
parent 104fa20399
commit 55d9b213cf
1 changed files with 19 additions and 18 deletions

View File

@ -19,25 +19,26 @@ DESCRIPTION="Utility to build live systems"
HELP="" HELP=""
USAGE="lb {clean|config|build}" USAGE="lb {clean|config|build}"
case "${1}" in # This bits of code relies on the fact that we only accept
-h|--help) # options without values before the real command.
if [ $(which man) ]; then GLOBAL_ARGS=""
man lb while true; do
else case $1 in
Usage -*)
fi GLOBAL_ARGS="${GLOBAL_ARGS:+$GLOBAL_ARGS }$1"
exit 0 shift
;; ;;
*)
break
;;
esac
done
Arguments $GLOBAL_ARGS
""|-u|--usage) if [ $# = 0 ]; then
Usage Echo_error "Missing sub-command"
;; Usage --fail
fi
-v|--version)
echo "${VERSION}"
exit 0
;;
esac
COMMAND="${1}" COMMAND="${1}"
shift shift