forked from zsh-users/zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_pear
84 lines (70 loc) · 2.05 KB
/
_pear
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
74
75
76
77
78
79
80
81
82
83
84
#compdef pear
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Pear (http://pear.php.net).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * aki77 (https://github.com/aki77)
#
# ------------------------------------------------------------------------------
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
# ------------------------------------------------------------------------------
_pear () {
local curcontext="$curcontext" state line expl ret=1
_arguments \
'1: :->subcmds' \
'*:: :->args' && ret=0
case $state in
subcmds)
_pear_commands
;;
args)
local cmd args
cmd=$words[1]
args=()
case $cmd in
channel-alias|channel-delete|channel-info|channel-update)
args+=(
':channel:_pear_discovered_channels'
)
;;
uninstall|upgrade|run-scripts)
args+=(
':package:_pear_installed_packages'
)
;;
esac
_arguments "$args[@]" && ret=0
return
;;
esac
return ret
}
_pear_commands () {
local commands
commands=(
${${(f)${"$(_call_program commands $service 2>&1)"#*Commands:}%Usage:*}/[[:blank:]]*[[:blank:]][[:blank:]]/:}
)
_describe -t commands 'Pear commands' commands
}
_pear_installed_packages () {
local packages
packages=(
${${(f)"$(pear list)"#*STATE}%%[[:blank:]]*}
)
_wanted package expl 'package' compadd -a packages
}
_pear_discovered_channels () {
local channels
channels=(
${${${(f)"$(_call_program commands pear list-channels)"#*SUMMARY}%__uri*}%%[[:blank:]]*}
)
_wanted channel expl 'channel' compadd -a channels
}
_pear "$@"