aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Benjamin Althues2013-05-26 18:20:39 +0200
committerGravatar Benjamin Althues2013-05-26 18:20:39 +0200
commit5c0189e9ca1cda9405cb2cfddf369945a39ace48 (patch)
tree69eaa58823c8e1ce46c277f9c1e647fbb8076414
parentdd41bb12727efc0d9951bb8ffd10d30f949e4b85 (diff)
downloadgitto-5c0189e9ca1cda9405cb2cfddf369945a39ace48.tar.gz
gitto-5c0189e9ca1cda9405cb2cfddf369945a39ace48.zip
Add zsh command completion function
Add completion for gitto (sub)commands and arguments for users of the Z shell.
-rw-r--r--zsh/_gitto73
1 files changed, 73 insertions, 0 deletions
diff --git a/zsh/_gitto b/zsh/_gitto
new file mode 100644
index 0000000..aefdb07
--- /dev/null
+++ b/zsh/_gitto
@@ -0,0 +1,73 @@
+#compdef gitto
+
+# gitto -- ZSH completion for gitto
+# Copyright (C) 2013 Benjamin Althues <benjamin at babab dot nl>
+
+# This file is part of gitto.
+
+# gitto is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# gitto is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with gitto. If not, see <http://www.gnu.org/licenses/>.
+
+local expl
+local -a repository_locations
+local -a _gitto_commands _gitto_config_commands _gitto_list_commands
+
+get_repository_locations() {
+ repository_locations=(${(f)"$(_call_program repository_locations \
+ gitto list locations 2>/dev/null)"})
+ _wanted repository_locations expl 'repository locations' \
+ compadd -a repository_locations
+}
+
+_gitto_commands=(
+ "add:register a new repository directory"
+ "check:check if a repository has been registered"
+ "config:show each repository's configuration"
+ "help:display help"
+ "list:list all repositories and their status"
+ "purge:remove all repositories that don't exist"
+ "remove:remove a repository directory"
+ "version:display version"
+)
+_gitto_config_commands=(
+ "global:show template configuration"
+ 'hooks:install configured hooks for repositories'
+ "update:merge template configuration with each repository's configuration"
+)
+_gitto_list_commands=(
+ "locations:list all registered repositories' locations"
+)
+
+_arguments '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+ _describe -t commands "gitto command" _gitto_commands
+ return 0
+fi
+
+case "$words[1]" in
+ add|check)
+ _files -/ && return 0 ;;
+ config)
+ _describe -t commands "gitto config command" _gitto_config_commands
+ return 0 ;;
+ help|purge|version)
+ return 0 ;;
+ list)
+ _describe -t commands "gitto list command" _gitto_list_commands
+ return 0 ;;
+ remove)
+ get_repository_locations && return 0
+esac
+
+# vim: set ft=zsh et ts=2 sw=2 sts=2: