aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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