_pod 4.66 KB
Newer Older
1
#compdef pod
Alexandre Joly's avatar
Alexandre Joly committed
2
#autoload
3
4
5
6

# -----------------------------------------------------------------------------
#          FILE:  pod.plugin.zsh
#   DESCRIPTION:  Cocoapods autocomplete plugin for Oh-My-Zsh
Alexandre Joly's avatar
Alexandre Joly committed
7
#                 http://cocoapods.org
8
9
#        AUTHOR:  Alexandre Joly (alexandre.joly@mekanics.ch)
#        GITHUB:  https://github.com/mekanics
Alexandre Joly's avatar
Alexandre Joly committed
10
#       TWITTER:  @jolyAlexandre
11
#       VERSION:  0.0.1
Alexandre Joly's avatar
Alexandre Joly committed
12
#       LICENSE:  MIT
13
14
# -----------------------------------------------------------------------------

Alexandre Joly's avatar
Alexandre Joly committed
15
16
17
18
19
20
21
22
23
24
25
26
#------------------
# TODO:
#   - Parameters for
#       - install
#       - update
#       - outdated
#       - search
#       - list
#       - push
#       - podfile-info
#       - setup
#------------------
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43

local -a _1st_arguments
_1st_arguments=(
    'help:Show help for the given command.'
    'install:Install project dependencies'
    'ipc:Inter-process communication'
    'list:List pods'
    'outdated:Show outdated project dependencies'
    'podfile-info:Shows information on installed Pods'
    'push:Push new specifications to a spec-repo'
    'repo:Manage spec-repositories'
    'search:Searches for pods'
    'setup:Setup the CocoaPods environment'
    'spec:Manage pod specs'
    'update:Update outdated project dependencies'
)

Alexandre Joly's avatar
Alexandre Joly committed
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
local -a _repo_arguments
_repo_arguments=(
    'add:Add a spec repo'
    'lint:Validates all specs in a repo'
    'update:Update a spec repo'
)

local -a _spec_arguments
_spec_arguments=(
    'cat:Prints a spec file'
    'create:Create spec file stub'
    'edit:Edit a spec file'
    'lint:Validates a spec file'
    'which:Prints the path of the given spec'
)

local -a _ipc_arguments
_ipc_arguments=(
    'list:Lists the specifications know to CocoaPods'
    'podfile:Converts a Podfile to YAML'
    'repl:The repl listens to commands on standard input'
    'spec:Converts a podspec to YAML'
    'update-search-index:Updates the search index'
)

local -a _list_arguments
_list_arguments=(
    'new:Lists pods introduced in the master spec-repo since the last check'
)

__first_command_list ()
{
    local expl
    declare -a tasks

Alexandre Joly's avatar
Alexandre Joly committed
79
    tasks=(install ipc list outdated podfile-info push repo search setup spec update)
Alexandre Joly's avatar
Alexandre Joly committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114

    _wanted tasks expl 'help' compadd $tasks
}

__repo_list() {
    _wanted application expl 'command' compadd $(command ls -1 ~/.cocoapods 2>/dev/null | sed -e 's/ /\\ /g')
}

__pod-repo() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        ':command:->command' \
        '*::options:->options'

   case $state in
       (command)
           _describe -t commands "gem subcommand" _repo_arguments
           return
       ;;

       (options)
           case $line[1] in
               (update|lint)
                   _arguments ':feature:__repo_list'
               ;;
           esac
       ;;
    esac
}

__pod-spec() {
    local curcontext="$curcontext" state line
    typeset -A opt_args
115

Alexandre Joly's avatar
Alexandre Joly committed
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
    _arguments -C \
        ':command:->command' \
        '*::options:->options'

   case $state in
        (command)
            _describe -t commands "gem subcommand" _spec_arguments
            return
        ;;

        (options)
            #todo
            return
        ;;
    esac
}

__pod-ipc() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        ':command:->command' \
        '*::options:->options'

   case $state in
        (command)
            _describe -t commands "gem subcommand" _ipc_arguments
            return
        ;;

        (options)
            #todo
            return
        ;;
    esac
}

Alexandre Joly's avatar
Alexandre Joly committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
__pod-list() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        ':command:->command' \
        '*::options:->options'

   case $state in
        (command)
            _describe -t commands "gem subcommand" _list_arguments
            return
        ;;

        (options)
            #todo
            return
        ;;
    esac
}

Alexandre Joly's avatar
Alexandre Joly committed
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198


local expl
#local -a boxes installed_boxes

local curcontext="$curcontext" state line
typeset -A opt_args

_arguments -C \
    ':command:->command' \
    '*::options:->options'

case $state in
  (command)
      _describe -t commands "gem subcommand" _1st_arguments
      return
  ;;

  (options)
    case $line[1] in
        (help)
            _arguments ':feature:__first_command_list'
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
199
200
201
202
        (push)
            _arguments ':feature:__repo_list'
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
        (repo)
            __pod-repo
        ;;

        (spec)
            __pod-spec
        ;;

        (ipc)
            __pod-ipc
        ;;

        (list)
            __pod-list
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
219
        (install|outdated|podfile-info|search|setup|update)
Alexandre Joly's avatar
Alexandre Joly committed
220
221
222
223
            #_arguments ':feature:__repo_list'
    esac
  ;;
esac