diff --git a/bash/src/base.args.sh b/bash/src/base.args.sh index 6ce3278..be4c313 100644 --- a/bash/src/base.args.sh +++ b/bash/src/base.args.sh @@ -235,25 +235,34 @@ function __parse_args() { if [ -n "$__DESC" ]; then help="$help: $__DESC" fi + + local prefix=" $MYNAME " + local -a usages; local usage="$__USAGE" + [ -n "$usage" ] || usage="[options]" + IFS=$'\n' read -a usages -d "" <<<"$usage" help="$help -USAGE - $MYNAME" - if [ -n "$__USAGE" ]; then - help="$help $__USAGE" - else - help="$help [options]" - fi - help="$help +USAGE" + for usage in "${usages[@]}"; do + [ -n "$usage" ] || continue + help="$help +$prefix$usage" + done -OPTIONS" set -- "${__DEFS[@]}" + local first=1 while [ $# -gt 0 ]; do case "$1" in +) shift; continue;; -) shift; continue;; -*) IFS=, read -a __defs <<<"$1"; shift;; esac + if [ -n "$first" ]; then + first= + help="$help + +OPTIONS" + fi # est-ce que l'option prend un argument? __witharg= for __def in "${__defs[@]}"; do