parse_args: usage peut maintenant être sur plusieurs lignes
This commit is contained in:
parent
7cac433cbc
commit
a1f88e9d38
|
@ -235,25 +235,34 @@ function __parse_args() {
|
||||||
if [ -n "$__DESC" ]; then
|
if [ -n "$__DESC" ]; then
|
||||||
help="$help: $__DESC"
|
help="$help: $__DESC"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local prefix=" $MYNAME "
|
||||||
|
local -a usages; local usage="$__USAGE"
|
||||||
|
[ -n "$usage" ] || usage="[options]"
|
||||||
|
IFS=$'\n' read -a usages -d "" <<<"$usage"
|
||||||
help="$help
|
help="$help
|
||||||
|
|
||||||
USAGE
|
USAGE"
|
||||||
$MYNAME"
|
for usage in "${usages[@]}"; do
|
||||||
if [ -n "$__USAGE" ]; then
|
[ -n "$usage" ] || continue
|
||||||
help="$help $__USAGE"
|
help="$help
|
||||||
else
|
$prefix$usage"
|
||||||
help="$help [options]"
|
done
|
||||||
fi
|
|
||||||
help="$help
|
|
||||||
|
|
||||||
OPTIONS"
|
|
||||||
set -- "${__DEFS[@]}"
|
set -- "${__DEFS[@]}"
|
||||||
|
local first=1
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
+) shift; continue;;
|
+) shift; continue;;
|
||||||
-) shift; continue;;
|
-) shift; continue;;
|
||||||
-*) IFS=, read -a __defs <<<"$1"; shift;;
|
-*) IFS=, read -a __defs <<<"$1"; shift;;
|
||||||
esac
|
esac
|
||||||
|
if [ -n "$first" ]; then
|
||||||
|
first=
|
||||||
|
help="$help
|
||||||
|
|
||||||
|
OPTIONS"
|
||||||
|
fi
|
||||||
# est-ce que l'option prend un argument?
|
# est-ce que l'option prend un argument?
|
||||||
__witharg=
|
__witharg=
|
||||||
for __def in "${__defs[@]}"; do
|
for __def in "${__defs[@]}"; do
|
||||||
|
|
Loading…
Reference in New Issue