Loading bashopts.sh +10 −9 Original line number Diff line number Diff line Loading @@ -271,13 +271,13 @@ bashopts_declare() { if ! [[ -v options[check] ]]; then options[check]="bashopts_check_${options[type]}" fi # Check the default value format options[default]="$(${options[check]} "${options[default]}")" || exit 1 # format the option method case "${options[method]}" in ''|s|set) # default: simple value - override options[method]="set" # Check the default value format options[default]="$(${options[check]} "${options[default]}")" || exit 1 ;; a|add) # array value - add Loading Loading @@ -401,15 +401,16 @@ bashopts_diplay_help() { # display additional information the each properties # discarding special options like --help if [[ -v bashopts_optprop_expression[$op] ]]; then dval="\"${bashopts_optprop_expression[$op]//\"/\\\"}\"" fi elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:\"${bashopts_optprop_expression[$op]//\"/\\\"}\")" elif [[ -v bashopts_optprop_default[$op] ]]; then if [ "${bashopts_optprop_type[$op]}" == "string" ]; then dval=${dval:-"\"${bashopts_optprop_default[$op]//\"/\\\"}\""} elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:\"${bashopts_optprop_default[$op]//\"/\\\"}\")" else elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:${bashopts_optprop_default[$op]})" fi else dval=${dval:-${bashopts_optprop_default[$op]}} elts="- [\$$op] (type:${bashopts_optprop_type[$op]})" fi # add type and default value info elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:$dval)" fi # display arguments, value if available, description, and additional info if available printf " %-${optargs_max_len}s %s\n" "${optargs[$op]}" "${bashopts_optprop_description[$op]} $elts" Loading test.sh +9 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,15 @@ _test_case_22() { bashopts_process_option -n value -k is_eq_to_null -r } _test_case_23() { bashopts_setup -n "$0" -d "Test case $0" bashopts_declare -n value -l value -m add -d "A str value" -t string -k is_eq_to_null bashopts_parse_args bashopts_process_opts } _test() { bashopts_setup -n "$0" -d "Test case $0" Loading Loading
bashopts.sh +10 −9 Original line number Diff line number Diff line Loading @@ -271,13 +271,13 @@ bashopts_declare() { if ! [[ -v options[check] ]]; then options[check]="bashopts_check_${options[type]}" fi # Check the default value format options[default]="$(${options[check]} "${options[default]}")" || exit 1 # format the option method case "${options[method]}" in ''|s|set) # default: simple value - override options[method]="set" # Check the default value format options[default]="$(${options[check]} "${options[default]}")" || exit 1 ;; a|add) # array value - add Loading Loading @@ -401,15 +401,16 @@ bashopts_diplay_help() { # display additional information the each properties # discarding special options like --help if [[ -v bashopts_optprop_expression[$op] ]]; then dval="\"${bashopts_optprop_expression[$op]//\"/\\\"}\"" fi elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:\"${bashopts_optprop_expression[$op]//\"/\\\"}\")" elif [[ -v bashopts_optprop_default[$op] ]]; then if [ "${bashopts_optprop_type[$op]}" == "string" ]; then dval=${dval:-"\"${bashopts_optprop_default[$op]//\"/\\\"}\""} elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:\"${bashopts_optprop_default[$op]//\"/\\\"}\")" else elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:${bashopts_optprop_default[$op]})" fi else dval=${dval:-${bashopts_optprop_default[$op]}} elts="- [\$$op] (type:${bashopts_optprop_type[$op]})" fi # add type and default value info elts="- [\$$op] (type:${bashopts_optprop_type[$op]}, default:$dval)" fi # display arguments, value if available, description, and additional info if available printf " %-${optargs_max_len}s %s\n" "${optargs[$op]}" "${bashopts_optprop_description[$op]} $elts" Loading
test.sh +9 −0 Original line number Diff line number Diff line Loading @@ -339,6 +339,15 @@ _test_case_22() { bashopts_process_option -n value -k is_eq_to_null -r } _test_case_23() { bashopts_setup -n "$0" -d "Test case $0" bashopts_declare -n value -l value -m add -d "A str value" -t string -k is_eq_to_null bashopts_parse_args bashopts_process_opts } _test() { bashopts_setup -n "$0" -d "Test case $0" Loading