-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws-upload.plugin.zsh
55 lines (49 loc) · 1.74 KB
/
aws-upload.plugin.zsh
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
#compdef aws-upload
function __aws-upload() {
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments \
'1: :->project'\
'2: :->env'
_projects=(${$(aws-upload -q -p)})
_keys=(${$(aws-upload -q -k):t})
_key_commands=("edit copy diff export check delete")
case $state in
project)
#echo "sono in proj"
#compadd "$@" $_commands
compadd "$@" $_projects
_values "aws-upload command:" \
"check[check a setting file]" \
"edit[edit a setting file]" \
"diff[get different file to sync]" \
"copy[copy a setting file]" \
"import[import a setting file]" \
"export[export a setting file]" \
"delete[delete a setting file]" \
"new[create a new setting file]"
;;
env)
# echo "1w1 :: $words[1] w2:: $words[2] \n"
if [[ $words[2] == "-e" ]]
then
compadd "$@" $_projects
fi
if [[ ${_key_commands[@]} =~ $words[2] ]]
then
compadd "$@" $_keys
fi
if [[ $words[2] != "-p" && $words[2] != "-e" && $word[2] != "edit" && $word[2] != "check" && $word[2] != "copy" && $word[2] != "diff" ]]
then
if [[ $words[2] = *[!\ ]* ]]
then
# just for debugging
# echo "w1 :: $words[1] w2:: $words[2] \n"
_envs=(${$(aws-upload -q -e $words[2]):t})
compadd "$@" $_envs
fi
fi
;;
esac
}
compdef __aws-upload aws-upload