forked from sbstp/kubie
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic autocompletion for zsh. (sbstp#34)
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
function _kubie { | ||
local -a subcmds | ||
local context state line | ||
|
||
_arguments -C \ | ||
'1: :->param1' \ | ||
'2: :->param2' \ | ||
'3: :->param3' && return 0 | ||
|
||
case $state in | ||
param1) | ||
subcmds=('ctx' 'edit' 'edit-config' 'exec' 'help' 'info' 'lint' 'ns') | ||
_describe 'command' subcmds | ||
;; | ||
param2) | ||
case $line[1] in | ||
ctx|edit|exec) | ||
subcmds=(${(f)"$(kubie ctx)"}) | ||
_describe 'context' subcmds | ||
;; | ||
ns) | ||
subcmds=(${(f)"$(kubie ns)"}) | ||
_describe 'namespace' subcmds | ||
;; | ||
esac | ||
;; | ||
param3) | ||
if [[ $line[1] == 'exec' ]]; then | ||
subcmds=(${(f)"$(kubie exec $line[2] default kubectl get namespaces | tail -n+2 | awk '{print $1}')"}) | ||
_describe 'namespace' subcmds | ||
fi | ||
;; | ||
esac | ||
} | ||
|
||
compdef _kubie kubie |