Commit f64f1fbb authored by Emeric Verschuur's avatar Emeric Verschuur
Browse files

[FIX] add test case 24 & minor upadtes

* Fix interactive not re ask in check failure
* Add bashopts_export_opts function
* README update
* Remove deprecated function
parent c8951fab
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ bashopts_declare option list:
 - ```-d <val>```: Option description
 - ```-t <val>```: Value type: string, number, boolean (default)
 - ```-m <val>```: Method: set (DEFAULT: simple value where $<variable name> will be a simple value), add (list with several values where $<variable name> will be a bash array)
 - ```-k <val>```: Custom check method (bash function like bashopts_check_number in bashopts.sh file)
 - ```-r```: Value required
 - ```-i```: Enable interactive edition
 - ```-s```: Store this in setting"
+6 −3
Original line number Diff line number Diff line
@@ -631,7 +631,6 @@ bashopts_process_option() {
                        # non array/normal value
                        if ! tval="$($check "$tval")"; then
                            unset tval
                            break
                        fi
                    fi
                    if [[ -v tval ]]; then
@@ -691,6 +690,10 @@ bashopts_process_opts() {
    fi
}

bashopts_process_args() {
    bashopts_process_opts "$@"
bashopts_export_opts() {
    for op in "${bashopts_optlist[@]}"; do
        if [[ -v $op ]]; then
            export $op
        fi
    done
}
+12 −0
Original line number Diff line number Diff line
@@ -348,6 +348,18 @@ _test_case_23() {
    bashopts_process_opts
}

_test_case_24() {
    bashopts_setup -n "$0" -d "Test case $0"

    bashopts_declare -n value -l value -d "A str value" -t string

    bashopts_parse_args
    bashopts_process_opts
    # NOTE: Fix answer again after a is_eq_to_null check failure
    req_test_eq "$( (bashopts_process_option -n value -k is_eq_to_null -r 2>&1 <<< "NUL" \
        || true) | grep -E '^* A str value$' | wc -l )" "2"
}

_test() {
    bashopts_setup -n "$0" -d "Test case $0"