summaryrefslogtreecommitdiff
path: root/provides/zsh/completions/_ct
diff options
context:
space:
mode:
Diffstat (limited to 'provides/zsh/completions/_ct')
-rw-r--r--provides/zsh/completions/_ct89
1 files changed, 89 insertions, 0 deletions
diff --git a/provides/zsh/completions/_ct b/provides/zsh/completions/_ct
new file mode 100644
index 0000000..c0af61b
--- /dev/null
+++ b/provides/zsh/completions/_ct
@@ -0,0 +1,89 @@
+#compdef ct
+## vim:ft=zsh
+## caretaker completion
+
+typeset expl
+
+function _ct_action () {
+ _wanted action expl 'action' \
+ compadd add eval remove info list \
+ log pull push refresh status update
+}
+
+function _ct_installed () {
+ _wanted package expl 'local package' \
+ compadd $(ct list local)
+}
+
+function _ct_all () {
+ _wanted package expl 'package' \
+ compadd $(ct list all)
+}
+
+function _ct_notinstalled () {
+ _wanted package expl 'remote package' \
+ compadd $(ct list not-installed)
+}
+
+function _ct_args {
+ if (( CURRENT == 2 )) {
+ case ${words[1]} in
+ l|log|f|pull|p|push|r|refresh|rm|remove|s|status)
+ _ct_installed
+ ;;
+ i|info)
+ _ct_all
+ ;;
+ a|add)
+ _ct_notinstalled
+ ;;
+ e|eval)
+ _message 'shell code for evaluation'
+ _wanted function expl 'internal function' \
+ compadd $(grep -E '^\S*\s*\(\)\s*{' =ct | cut -d ' ' -f 1) \
+ $(grep -E 'function \S* (\(\) )?{' =ct | cut -d ' ' -f 2)
+ ;;
+ ls|list)
+ _wanted something expl 'list mode' \
+ compadd all local not-installed
+ ;;
+ u|update)
+ _wanted mode expl 'update target' \
+ compadd local remote
+ ;;
+ *)
+ _message 'no more arguments'
+ ;;
+ esac
+ } elif [[ ${words[1]} == e(val|) ]] {
+ _message 'shell code for evaluation'
+ if (( CURRENT == 3 )) {
+ case ${words[2]} in
+ exec_hook|check_prereqs|*_collected|)
+ _ct_installed
+ ;;
+ esac
+ } elif (( CURRENT == 4 )) {
+ case ${words[2]} in
+ exec_hook)
+ _wanted hook expl 'package hook' \
+ compadd $(ls -1 ~/packages/${words[3]}/hooks 2> /dev/null)
+ ;;
+ esac
+ }
+ }
+}
+
+_arguments \
+ '--quiet[quiet mode]' \
+ '--debug[debugmode]' \
+ '--auto-update[automatically update package list]' \
+ '*--checklinks-options[options for checklinks]:option' \
+ '--packagedir[package directory]:directory:_files -/' \
+ '--packageroot[package root]:url' \
+ '--colours[use colours]' \
+ '--no-colours[No colours]' \
+ '--progress[show progress bar]' \
+ '--no-progress[No progress bar]' \
+ ':action:_ct_action' \
+ '*::arguments:_ct_args'