Skip to content

Commit

Permalink
mkr-completion.zsh by itchyny
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Nov 17, 2015
1 parent c89f101 commit e0c7e51
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions contrib/completion/mkr-completion.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#compdef mkr

_mkr ()
{

_arguments -C \
'1: :->cmds' \
'*: :->args' \
&& ret=0

local -a list

if ! command -v mkr > /dev/null 2>&1; then
return 0
fi

case $state in

(cmds)
list=( ${(f)"$(mkr | sed '1,/COMMANDS/d;/GLOBAL OPTIONS/,$d' | sed 's/^ *//' | sed -E s/$'\t'+/:/ | sed 's/, h//')"} )
_describe -t commands 'Commands' list && ret=0
;;

(args)
case $line[1] in
(status|update|retire)
list=( ${(f)"$(mkr hosts -f '{{range .}}{{.ID}}{{":"}}{{.Name}}{{"\n"}}{{end}}')"} )
_describe -t plugins 'Hosts' list && ret=0
;;
(*)
_nothing
;;
esac
;;

esac
}

return 0

0 comments on commit e0c7e51

Please sign in to comment.