summaryrefslogtreecommitdiff
path: root/plugins/pod/_pod
blob: ce8882d421ead3fff45db3e79b0919cbe952a905 (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
74
75
76
77
78
79
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
115
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#compdef pod
#autoload

# -----------------------------------------------------------------------------
#          FILE:  pod.plugin.zsh
#   DESCRIPTION:  Cocoapods autocomplete plugin for Oh-My-Zsh
#                 http://cocoapods.org
#        AUTHOR:  Alexandre Joly (alexandre.joly@mekanics.ch)
#        GITHUB:  https://github.com/mekanics
#       TWITTER:  @jolyAlexandre
#       VERSION:  0.0.1
#       LICENSE:  MIT
# -----------------------------------------------------------------------------

#------------------
# TODO:
#   - Parameters for
#       - install
#       - update
#       - outdated
#       - search
#       - list
#       - push
#       - podfile-info
#       - setup
#------------------

local -a _1st_arguments
_1st_arguments=(
    'help:Show help for the given command.'
    'install:Install project dependencies'
    'ipc:Inter-process communication'
    'lib:Develop pods'
    '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'
)

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

    tasks=(install ipc lib list outdated podfile-info push repo search setup spec update)

    _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

    _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
}



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'
        ;;

        (repo)
            __pod-repo
        ;;

        (spec)
            __pod-spec
        ;;

        (ipc)
            __pod-ipc
        ;;

        (list)
            __pod-list
        ;;

        (install|lib|outdated|podfile-info|push|search|setup|update)
            #_arguments ':feature:__repo_list'
    esac
  ;;
esac