Loading CHANGELOG.md +4 −0 Original line number Diff line number Diff line # Changelog ## 2.1.1 * Fix enumeration type to support values with spaces * Improve join_by to support multi character separator ## 2.1.0 * Improve the help display for big size values Loading VERSION +1 −1 Original line number Diff line number Diff line 2.2.0 2.1.1 bashopts.sh +9 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ set -e BASHOPTS_VERSION=2.1.0 BASHOPTS_VERSION=2.1.1 bashopts_exit_handle() { local err=$? Loading Loading @@ -256,7 +256,7 @@ bashopts_declare() { -l) options[long_opt]=$1; shift;; -d) options[description]=$1; shift;; -t) options[type]=$1; shift;; -e) options_enum_values+=($1); shift;; -e) options_enum_values+=("$1");shift;; -m) options[method]=$1; shift;; -k) options[check]=$1; shift;; -s) options[setting]="true";; Loading @@ -280,7 +280,7 @@ bashopts_declare() { if [ ${#options_enum_values[@]} -lt 2 ]; then bashopts_log C "bashopts_declare: ${options[name]} enumeration need at least two elements (two '-e <val>' calls at least)" fi options[enum_values]="$(IFS=$'\n'; echo "${options_enum_values[*]}")" options[enum_values]="$(printf "%s\n" "${options_enum_values[@]}")" ;; s|str|string) options[type]="string" Loading Loading @@ -387,9 +387,12 @@ bashopts_math_min() { # join array element bashopts_join_by() { local IFS="$1" shift || bashopts_log C "Usage: bashopts_join_by <character> [elt1 [elt2...]]" echo "$*" local sep="$1" shift || bashopts_log C "Usage: bashopts_join_by <separator> [elt1 [elt2...]]" printf "%s" "$1" test $# -gt 1 || return 0 shift printf "$sep%s" "$@" } # dump an option value by its name Loading Loading
CHANGELOG.md +4 −0 Original line number Diff line number Diff line # Changelog ## 2.1.1 * Fix enumeration type to support values with spaces * Improve join_by to support multi character separator ## 2.1.0 * Improve the help display for big size values Loading
bashopts.sh +9 −6 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ set -e BASHOPTS_VERSION=2.1.0 BASHOPTS_VERSION=2.1.1 bashopts_exit_handle() { local err=$? Loading Loading @@ -256,7 +256,7 @@ bashopts_declare() { -l) options[long_opt]=$1; shift;; -d) options[description]=$1; shift;; -t) options[type]=$1; shift;; -e) options_enum_values+=($1); shift;; -e) options_enum_values+=("$1");shift;; -m) options[method]=$1; shift;; -k) options[check]=$1; shift;; -s) options[setting]="true";; Loading @@ -280,7 +280,7 @@ bashopts_declare() { if [ ${#options_enum_values[@]} -lt 2 ]; then bashopts_log C "bashopts_declare: ${options[name]} enumeration need at least two elements (two '-e <val>' calls at least)" fi options[enum_values]="$(IFS=$'\n'; echo "${options_enum_values[*]}")" options[enum_values]="$(printf "%s\n" "${options_enum_values[@]}")" ;; s|str|string) options[type]="string" Loading Loading @@ -387,9 +387,12 @@ bashopts_math_min() { # join array element bashopts_join_by() { local IFS="$1" shift || bashopts_log C "Usage: bashopts_join_by <character> [elt1 [elt2...]]" echo "$*" local sep="$1" shift || bashopts_log C "Usage: bashopts_join_by <separator> [elt1 [elt2...]]" printf "%s" "$1" test $# -gt 1 || return 0 shift printf "$sep%s" "$@" } # dump an option value by its name Loading