Skip to content

Commit f48b9c4

Browse files
author
Damien Nadé
committed
argsparse-completion.sh: __argsparse_complete_get_long function
1 parent 712935f commit f48b9c4

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

argsparse-completion.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,24 @@ __argsparse_complete_value() {
6565
fi
6666
}
6767

68+
__argsparse_complete_get_long() {
69+
[[ $# -ge 1 ]] || return 1
70+
local word=$1
71+
shift
72+
local -a longs=( "$@" )
73+
local long
74+
if [[ $word = -+([!-]) ]] && \
75+
long=$(argsparse_short_to_long "${word:${#word}-1}")
76+
then
77+
printf %s "$long"
78+
elif __argsparse_index_of "$word" "${longs[@]}" >/dev/null
79+
then
80+
printf %s "${word#--}"
81+
else
82+
return 1
83+
fi
84+
}
85+
6886
__argsparse_complete() {
6987
local script=${words[0]}
7088
(

0 commit comments

Comments
 (0)