-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdev-tool-completion.bash
More file actions
134 lines (116 loc) · 3.23 KB
/
dev-tool-completion.bash
File metadata and controls
134 lines (116 loc) · 3.23 KB
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
134
# bash completion for dev-tool
_dev-tool() {
local cur prev words cword
_init_completion || return
case $prev in
dev-tool)
COMPREPLY=( $(compgen -W "crp git batch-git batch-crp config upgrade findicon help" -- "$cur") )
return 0
;;
crp)
COMPREPLY=( $(compgen -W "pack test projects topics instances branches gendoc" -- "$cur") )
return 0
;;
git)
COMPREPLY=( $(compgen -W "tag merge test lasttag release projects tag-local" -- "$cur") )
return 0
;;
batch-git)
COMPREPLY=( $(compgen -W "tag merge test lasttag release projects" -- "$cur") )
return 0
;;
batch-crp)
COMPREPLY=( $(compgen -W "pack test" -- "$cur") )
return 0
;;
findicon)
# 只补全选项,不补全图标名称以避免误导
return 0
;;
esac
case ${words[1]} in
crp)
_dev-tool_crp
;;
git)
_dev-tool_git
;;
batch-git)
_dev-tool_batch_git
;;
batch-crp)
_dev-tool_batch_crp
;;
findicon)
_dev-tool_findicon
;;
esac
}
_dev-tool_crp() {
local cur prev words cword
_init_completion || return
case $prev in
--name|--topic|--branch|--tag)
return 0
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--name --topic --branch --tag --help" -- "$cur") )
fi
}
_dev-tool_git() {
local cur prev words cword
_init_completion || return
case $prev in
--name|--org|--branch|--tag|--reviewer|--repo)
return 0
;;
esac
# 根据子命令提供不同的参数补全
case ${words[2]} in
tag-local)
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--repo --tag --verbose --quiet --help" -- "$cur") )
fi
;;
*)
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--name --org --branch --tag --reviewer --verbose --quiet --help" -- "$cur") )
fi
;;
esac
}
_dev-tool_batch_git() {
local cur prev words cword
_init_completion || return
case $prev in
--config|--org|--branch|--tag|--reviewer)
return 0
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--config --org --branch --tag --reviewer --help" -- "$cur") )
fi
}
_dev-tool_batch_crp() {
local cur prev words cword
_init_completion || return
case $prev in
--config|--topic|--branch|--tag)
return 0
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--config --topic --branch --tag --help" -- "$cur") )
fi
}
_dev-tool_findicon() {
local cur prev words cword
_init_completion || return
# 只为选项参数提供补全,不为图标名称提供补全
if [[ $cur == -* ]]; then
COMPREPLY=( $(compgen -W "--help" -- "$cur") )
fi
# 对于图标名称不提供补全,让用户自己输入
}
complete -F _dev-tool dev-tool