-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#compdef kerl | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Description | ||
# ----------- | ||
# | ||
# Completion script for kerl (http://github.com/spawngrid/kerl | ||
# | ||
# Source: https://github.com/sanmiguel/zsh-completions | ||
# | ||
# ------------------------------------------------------------------------------ | ||
# Authors | ||
# ------- | ||
# | ||
# * Michael Coles (https://github.com/sanmiguel) | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
# TODO: These are naive and stupid | ||
_kerl_available_releases() { | ||
releases=(${(f)"$(_call_program releases cat ~/.kerl/otp_releases)"}) | ||
} | ||
|
||
_kerl_builds() { | ||
builds=(${(f)"$(_call_program builds cut -f 2 -d "," ~/.kerl/otp_builds)"}) | ||
} | ||
|
||
_kerl_installations() { | ||
installations=(${(f)"$(_call_program installations kerl list installations 2>/dev/null)"}) | ||
} | ||
|
||
local -a _1st_arguments | ||
_1st_arguments=( | ||
'build:Build specified release or git repository' | ||
'install:Install the specified release at the given location' | ||
'deploy:Deploy the specified installation to the given host and location' | ||
'update:Update the list of available releases from erlang.org' | ||
'list:List releases, builds and installations' | ||
'delete:Delete builds and installations' | ||
'active:Print the path of the active installation' | ||
'status:Print available builds and installations' | ||
'prompt:Print a string suitable for insertion in prompt' | ||
'cleanup:Remove compilation artifacts (use after installation)' | ||
) | ||
|
||
local -a _list_options | ||
_list_options=( | ||
'releases:All available OTP releases' | ||
'builds:All locally built OTP releases' | ||
'installations:All locally installed OTP builds' | ||
) | ||
|
||
local expl | ||
local -a releases builds installations | ||
|
||
_arguments \ | ||
'*:: :->subcmds' && return 0 | ||
|
||
if (( CURRENT == 1 )); then | ||
_describe -t commands "kerl subcommand" _1st_arguments | ||
return | ||
fi | ||
|
||
case "$words[1]" in | ||
build) | ||
_arguments \ | ||
'1: :->rels' && return 0 | ||
|
||
if [[ "$state" == rels ]]; then | ||
_kerl_available_releases | ||
_wanted releases expl 'all releases' compadd -a releases | ||
fi;; | ||
install) | ||
_arguments \ | ||
'1: :->blds' && return 0 | ||
|
||
if [[ "$state" == blds ]]; then | ||
_kerl_builds | ||
_wanted builds expl 'all builds' compadd -a builds | ||
return | ||
fi | ||
_directories | ||
;; | ||
deploy) _hosts;; # TODO: [directory] [remote directory] | ||
update) _describe "kerl update options" ('releases:Update releases list');; | ||
list) | ||
_describe "kerl list options" _list_options | ||
return | ||
;; | ||
delete) ;; | ||
active) ;; | ||
status) ;; | ||
prompt) ;; | ||
cleanup) ;; | ||
esac |