-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_cmd
53 lines (44 loc) · 1.33 KB
/
_cmd
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
#compdef cmd
setopt localoptions warncreateglobal typesetsilent
local curcontext="$curcontext" state state_descr line ret=1
local -a expl
typeset -a commands
commands=(
run:'Execute a command'
edit:'Edit a command'
cat:'Display a command'
items:'Show available commands'
ctags:'Generate Emacs TAGS file'
examine:'Test if a command should be run and execute'
log:"Show command output"
stat:'Show command status'
new:'Create a new command'
)
_arguments -C \
'1: :->command'\
'*: :->argument' && ret=0
case $state in
command)
local -a cmd_path=( ${(s.:.)CMD_COMMAND_PATH} )
commands+=( $^cmd_path/*.(ini|cmd)(:t:rN) )
_describe -t commands "command-CI-server commands" commands && ret=0
;;
argument)
case $words[2] in
run|log|stat|edit|cat|examine)
# Find commands
local -TU CMD_PATH=$CMD_COMMAND_PATH cmd_path
local -a items
(( ! $#cmd_path ))&&return 3
items=( $^cmd_path/*.(ini|cmd)(N:t:r) )
(( ! $#items ))&&return 5
_wanted plugins expl "-- Command --" \
compadd "$@" -a - items && \
ret=0
;;
*)
ret=1
;;
esac
esac
return $ret