-
Notifications
You must be signed in to change notification settings - Fork 1
/
oapi-cli-completion-tpl.bash
43 lines (36 loc) · 1.1 KB
/
oapi-cli-completion-tpl.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#/usr/bin/env bash
____func_code____
_mk_profiles()
{
cur=${COMP_WORDS[COMP_CWORD]}
if [ -f ~/.osc/config.json ]; then
PROFILES=$(cat ~/.osc/config.json | tr -d '\n:' | sed 's/{[^{}]*}//g' | tr -d "{}\" " | sed 's/,/ /g')
fi
for x in $PROFILES ; do echo --profile=$x ; done
}
_cognac()
{
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ${COMP_CWORD} in
*)
case ${prev} in
____piped_call_list____)
eval ${prev}
;;
--help)
COMPREPLY=($(compgen -W "____call_list____" -- ${cur}))
;;
*)
PROFILES=$(_mk_profiles)
COMPREPLY=($(compgen -W "$PROFILES --config --login --password --authentication_method --color --insecure --raw-print --verbose --help -h --list-calls --version ____call_list____" -- ${cur}))
;;
esac
;;
esac
}
complete -F _cognac ____cli_name____
complete -F _cognac ____cli_name____-x86_64.AppImage
# thoses one are for debug
complete -F _cognac ./____cli_name____
complete -F _cognac ./____cli_name____-x86_64.AppImage