afficher correctement une option facultative

This commit is contained in:
Jephté Clain 2025-08-20 13:22:10 +04:00
parent 26821f2a1a
commit 7d4c385492

View File

@ -184,7 +184,7 @@ function __nulib_args_parse_args() {
*) die "Invalid arg definition: expected option, got '$1'" || return;;
esac
# est-ce que l'option prend un argument?
local __def __longdef __witharg __valdesc
local __def __longdef __witharg __valdesc __defvaldesc
__witharg=
for __def in "${__defs[@]}"; do
if [ "${__def%::*}" != "$__def" ]; then
@ -346,16 +346,19 @@ $prefix$usage"
fi
# est-ce que l'option prend un argument?
__witharg=
__valdesc=value
__valdesc=
__defvaldesc=value
for __def in "${__defs[@]}"; do
if [ "${__def%::*}" != "$__def" ]; then
[ "$__witharg" != : ] && __witharg=::
[ -n "${__def#*::}" ] && __valdesc="[${__def#*::}]"
__defvaldesc="[value]"
elif [ "${__def%:*}" != "$__def" ]; then
__witharg=:
[ -n "${__def#*:}" ] && __valdesc="${__def#*:}"
fi
done
[ -n "$__valdesc" ] || __valdesc="$__defvaldesc"
# description de l'option
local first=1 thelp tdesc
for __def in "${__defs[@]}"; do