-
Notifications
You must be signed in to change notification settings - Fork 0
/
lmrtfy_cli_completion
134 lines (108 loc) · 2.28 KB
/
lmrtfy_cli_completion
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# bash completion support for lmrtfy
# DO NOT EDIT.
# This script is autogenerated by fire/completion.py.
_complete-lmrtfy()
{
local cur prev opts lastcommand
COMPREPLY=()
prev="${COMP_WORDS[COMP_CWORD-1]}"
cur="${COMP_WORDS[COMP_CWORD]}"
lastcommand=$(get_lastcommand)
opts=""
GLOBAL_OPTIONS=""
case "${lastcommand}" in
submit)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--input-file --profile-id --self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
fetch)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--job-id --results-dir --self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
deploy)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--local --run-as-daemon --script-path --self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
lmrtfy)
opts="deploy fetch login logout submit ${GLOBAL_OPTIONS}"
opts=$(filter_options $opts)
;;
logout)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
login)
if is_prev_global; then
opts="${GLOBAL_OPTIONS}"
else
opts="--self ${GLOBAL_OPTIONS}"
fi
opts=$(filter_options $opts)
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
get_lastcommand()
{
local lastcommand i
lastcommand=
for ((i=0; i < ${#COMP_WORDS[@]}; ++i)); do
if [[ ${COMP_WORDS[i]} != -* ]] && [[ -n ${COMP_WORDS[i]} ]] && [[
${COMP_WORDS[i]} != $cur ]]; then
lastcommand=${COMP_WORDS[i]}
fi
done
echo $lastcommand
}
filter_options()
{
local opts
opts=""
for opt in "$@"
do
if ! option_already_entered $opt; then
opts="$opts $opt"
fi
done
echo $opts
}
option_already_entered()
{
local opt
for opt in ${COMP_WORDS[@]: 0: COMP_CWORD}
do
if [ $1 == $opt ]; then
return 0
fi
done
return 1
}
is_prev_global()
{
local opt
for opt in $GLOBAL_OPTIONS
do
if [ $opt == $prev ]; then
return 0
fi
done
return 1
}
complete -F _complete-lmrtfy lmrtfy