afficher correctement une option facultative
This commit is contained in:
parent
26821f2a1a
commit
7d4c385492
@ -184,7 +184,7 @@ function __nulib_args_parse_args() {
|
|||||||
*) die "Invalid arg definition: expected option, got '$1'" || return;;
|
*) die "Invalid arg definition: expected option, got '$1'" || return;;
|
||||||
esac
|
esac
|
||||||
# est-ce que l'option prend un argument?
|
# est-ce que l'option prend un argument?
|
||||||
local __def __longdef __witharg __valdesc
|
local __def __longdef __witharg __valdesc __defvaldesc
|
||||||
__witharg=
|
__witharg=
|
||||||
for __def in "${__defs[@]}"; do
|
for __def in "${__defs[@]}"; do
|
||||||
if [ "${__def%::*}" != "$__def" ]; then
|
if [ "${__def%::*}" != "$__def" ]; then
|
||||||
@ -346,16 +346,19 @@ $prefix$usage"
|
|||||||
fi
|
fi
|
||||||
# est-ce que l'option prend un argument?
|
# est-ce que l'option prend un argument?
|
||||||
__witharg=
|
__witharg=
|
||||||
__valdesc=value
|
__valdesc=
|
||||||
|
__defvaldesc=value
|
||||||
for __def in "${__defs[@]}"; do
|
for __def in "${__defs[@]}"; do
|
||||||
if [ "${__def%::*}" != "$__def" ]; then
|
if [ "${__def%::*}" != "$__def" ]; then
|
||||||
[ "$__witharg" != : ] && __witharg=::
|
[ "$__witharg" != : ] && __witharg=::
|
||||||
[ -n "${__def#*::}" ] && __valdesc="[${__def#*::}]"
|
[ -n "${__def#*::}" ] && __valdesc="[${__def#*::}]"
|
||||||
|
__defvaldesc="[value]"
|
||||||
elif [ "${__def%:*}" != "$__def" ]; then
|
elif [ "${__def%:*}" != "$__def" ]; then
|
||||||
__witharg=:
|
__witharg=:
|
||||||
[ -n "${__def#*:}" ] && __valdesc="${__def#*:}"
|
[ -n "${__def#*:}" ] && __valdesc="${__def#*:}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
[ -n "$__valdesc" ] || __valdesc="$__defvaldesc"
|
||||||
# description de l'option
|
# description de l'option
|
||||||
local first=1 thelp tdesc
|
local first=1 thelp tdesc
|
||||||
for __def in "${__defs[@]}"; do
|
for __def in "${__defs[@]}"; do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user