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