aboutsummaryrefslogtreecommitdiffstats
path: root/zsh_completion
diff options
context:
space:
mode:
authorsanmiguel <[email protected]>2013-11-20 17:05:51 +0000
committersanmiguel <[email protected]>2013-11-20 17:05:51 +0000
commitcfeea403c1092c4e9524fe82a6a73b62b60173d6 (patch)
treec43e483aa427d038eb2ce054ff83e25ea77d45ba /zsh_completion
parenteb2d4a10541255dc6fe52fe5fa37834390f6fe1a (diff)
downloadkerl-cfeea403c1092c4e9524fe82a6a73b62b60173d6.tar.gz
kerl-cfeea403c1092c4e9524fe82a6a73b62b60173d6.tar.bz2
kerl-cfeea403c1092c4e9524fe82a6a73b62b60173d6.zip
zsh-completion module for kerl
Diffstat (limited to 'zsh_completion')
-rw-r--r--zsh_completion/_kerl73
1 files changed, 59 insertions, 14 deletions
diff --git a/zsh_completion/_kerl b/zsh_completion/_kerl
index 628b3bf..10ae768 100644
--- a/zsh_completion/_kerl
+++ b/zsh_completion/_kerl
@@ -18,15 +18,16 @@
# TODO: These are naive and stupid
_kerl_available_releases() {
+ # we use the file directly as `kerl list releases` dumps extraneous data to stdout
releases=(${(f)"$(_call_program releases cat ~/.kerl/otp_releases)"})
}
_kerl_builds() {
- builds=(${(f)"$(_call_program builds cut -f 2 -d "," ~/.kerl/otp_builds)"})
+ builds=(${(f)"$(_call_program builds kerl list builds 2>/dev/null | cut -f 2 -d ",")"})
}
_kerl_installations() {
- installations=(${(f)"$(_call_program installations kerl list installations 2>/dev/null)"})
+ installations=(${(f)"$(_call_program installations kerl list installations 2>/dev/null | cut -f 2 -d " ")"})
}
local -a _1st_arguments
@@ -49,6 +50,10 @@ _list_options=(
'builds:All locally built OTP releases'
'installations:All locally installed OTP builds'
)
+local -a _update_options
+_update_options=(
+ 'releases:All available OTP releases'
+)
local expl
local -a releases builds installations
@@ -62,34 +67,74 @@ if (( CURRENT == 1 )); then
fi
case "$words[1]" in
+ active) ;;
+ status) ;;
+ prompt) ;;
build)
_arguments \
- '1: :->rels' && return 0
+ '1: :->rels' \
+ '2: :->buildnames' && return 0
if [[ "$state" == rels ]]; then
_kerl_available_releases
_wanted releases expl 'all releases' compadd -a releases
+ elif [[ "$state" == buildnames ]]; then
+
fi;;
+ # TODO: suggest build name as $(lowercase $release)
install)
_arguments \
- '1: :->blds' && return 0
+ '1: :->blds' \
+ '2::location:_path_files -W "(~/kerl)"' && return 0
if [[ "$state" == blds ]]; then
_kerl_builds
_wanted builds expl 'all builds' compadd -a builds
return
fi
+ # TODO: suggest starting location of "$KERLDIR/$(lowercase $build)"
_directories
;;
- deploy) _hosts;; # TODO: [directory] [remote directory]
- update) _describe "kerl update options" ('releases:Update releases list');;
+ deploy)
+ _arguments \
+ '1: :->hosts' \
+ '2: :->installs' && return 0
+
+ if [[ "$state" == hosts ]]; then
+ _hosts
+ return
+ elif [[ "$state" == installs ]]; then
+ _kerl_installations
+ _wanted installations expl 'all installations' compadd -a installations
+ return
+ fi
+ ;; # TODO: [remote directory] (or at least prompt)
+ update)
+ _arguments '1: :->updopts' && return 0
+ if [[ "$state" == updopts ]]; then _describe "kerl update options" _update_options; fi
+ ;;
list)
- _describe "kerl list options" _list_options
- return
- ;;
- delete) ;;
- active) ;;
- status) ;;
- prompt) ;;
- cleanup) ;;
+ _arguments '1: :->listopts' && return 0
+ if [[ "$state" == listopts ]]; then _describe "kerl list options" _list_options; fi
+ ;;
+ delete)
+ _arguments \
+ '1:<build|installation>:(build installation)' && return 0
+
+ case "$words[2]" in
+ build)
+ _kerl_builds
+ _wanted builds expl 'all builds' compadd -a builds
+ return
+ ;;
+ installation)
+ _kerl_installations
+ _wanted installations expl 'all installations' compadd -a installations
+ return
+ esac
+ ;;
+ cleanup)
+ _kerl_builds
+ builds=('all' $builds)
+ _wanted builds expl 'all builds' compadd -a builds;;
esac