aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/_sti
blob: 637d987c57d55c6654ab6c1c7cf0f8fc5ce04f68 (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
#compdef sti
# sti --- Stupid Tool Installer
# Copyright (C) 2014  Tom Willemse <tom@ryuslash.org>

# sti 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.

# sti 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 sti.  If not, see <http://www.gnu.org/licenses/>.

local expl
local -a sti_tools _sti_commands

get_tools() {
  if [[ "$state" == tools ]]; then
    sti_tools=(${(f)"$(_call_program sti_tools \
        sti list | awk '{ print $1 }' 2>/dev/null)"})
    _wanted sti_tools expl 'enabled tools' compadd -a sti_tools
  fi
}

_sti_commands=(
  'help:show help message'
  'install:install a tool from a git repository'
  'list:list downloaded tools'
  'reinit:retry installing the executables of a tool'
  'remove:remove an installed tool'
  'update:update an installed tool'
)

_arguments '*:: :->subcmds' && return 0

if (( CURRENT == 1 )); then
  _describe -t commands "sti command" _sti_commands
  return
fi

case "$words[1]" in
  h*)
    _describe -t commands "sti subcommands" _sti_commands
    return 0 ;;
  i* | l* )
    _arguments && return 0 ;;
  r* | u*)
    _arguments '*:: :->tools' && return 0
    get_tools ;;
esac

# vim: set ft=zsh et ts=2 sw=2 sts=2: