You've already forked sh-args-parser
mirror of
https://github.com/nikolaypronchev/sh-args-parser.git
synced 2026-04-17 14:06:32 +03:00
Fix "auto" value for _accept_* configurations
This commit is contained in:
21
parser.sh
21
parser.sh
@@ -139,19 +139,14 @@ _is_valid_var_name() {
|
|||||||
_command_required() {
|
_command_required() {
|
||||||
[ "$_accept_command" = "none" ] && return 1
|
[ "$_accept_command" = "none" ] && return 1
|
||||||
[ "$_accept_command" != "auto" ] && return 0
|
[ "$_accept_command" != "auto" ] && return 0
|
||||||
|
[ "$_mapped_commands_count" -gt 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
_i=1
|
_mapped_options_only() {
|
||||||
while [ "$_i" -le "$_mapped_commands_count" ]; do
|
[ "$_accept_options" = "none" ] && return 1
|
||||||
_command_auto_mapped=$(_var_value "_commands_${_i}_auto")
|
[ "$_accept_options" = "any" ] && return 1
|
||||||
|
[ "$_accept_options" = "mapped_only" ] && return 0
|
||||||
if _is_not "$_command_auto_mapped"; then
|
[ "$_mapped_options_count" -gt 0 ]
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
_i=$(_math "$_i + 1")
|
|
||||||
done
|
|
||||||
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_map_command() {
|
_map_command() {
|
||||||
@@ -714,7 +709,7 @@ _use_option() {
|
|||||||
_option_index=$(_get_mapped_option_index_by_alias "$1")
|
_option_index=$(_get_mapped_option_index_by_alias "$1")
|
||||||
|
|
||||||
if [ -z "$_option_index" ]; then
|
if [ -z "$_option_index" ]; then
|
||||||
if [ "$_accept_options" = "mapped_only" ]; then
|
if _mapped_options_only; then
|
||||||
_err "Unknown option: $1."
|
_err "Unknown option: $1."
|
||||||
else
|
else
|
||||||
_map_option_auto "$1"
|
_map_option_auto "$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user