Support validator question argument for select

This commit is contained in:
Rezart Qelibari
2022-02-17 17:51:31 +01:00
parent 90758b2fdd
commit eae2abbb01
2 changed files with 9 additions and 0 deletions

View File

@@ -119,6 +119,7 @@ function convertQuestionArgsToAskUserArgs() {
choices=("${(s.,.)argValue}")
[ "${#choices}" -ge 1 ] || return 11
args=(choose)
findQuestionArgInInstruction 'validator' && args+=(-v ${argValue})
fi
return 0
}

View File

@@ -53,6 +53,14 @@ Describe 'convertQuestionArgsToAskUserArgs'
The variable '#choices' should eq 3
End
It 'converts validator to -v option for choose'
args=() choices=() questionArgs='select;validator:is_file;choose from:blue,light green,red'
When call convertQuestionArgsToAskUserArgs
The variable args should eq 'choose -v is_file'
The variable choices should eq 'blue light green red'
The variable '#choices' should eq 3
End
It 'finds choose from arg even if many args are provided'
args=() choices=() questionArgs='select;first arg:red;choose from:blue,light green,red;after arg:nine;after arg:nine;'
When call convertQuestionArgsToAskUserArgs