aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/_gitto
blob: aefdb0784f1e4096bf052f9cfdaa8835e29c6ba5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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: