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

# -----------------------------------------------------------------------------
mekanics's avatar
mekanics committed
5
#          FILE:  _pod
6
#   DESCRIPTION:  Cocoapods (0.33.0) 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.4
12
13
14
15
# -----------------------------------------------------------------------------

local -a _1st_arguments
_1st_arguments=(
16
17
    'help:Show help for the given command.'
    'init:Generate a Podfile for the current directory.'
18
19
    'install:Install project dependencies'
    'ipc:Inter-process communication'
20
    'lib:Develop pods'
21
22
    'list:List pods'
    'outdated:Show outdated project dependencies'
23
24
    'plugins:Show available CocoaPods plugins'
    'push:Temporary alias for the `pod repo push` command'
25
26
27
28
    'repo:Manage spec-repositories'
    'search:Searches for pods'
    'setup:Setup the CocoaPods environment'
    'spec:Manage pod specs'
29
30
    'trunk:Interact with trunk.cocoapods.org'
    'try:Try a Pod!'
31
32
33
    'update:Update outdated project dependencies'
)

Alexandre Joly's avatar
Alexandre Joly committed
34
35
36
37
local -a _repo_arguments
_repo_arguments=(
    'add:Add a spec repo'
    'lint:Validates all specs in a repo'
38
    'push:Push new specifications to a spec-repo'
39
    'remove:Remove a spec repo.'
Alexandre Joly's avatar
Alexandre Joly committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
    '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'
57
    'spec:Converts a podspec to JSON'
Alexandre Joly's avatar
Alexandre Joly committed
58
59
60
    'update-search-index:Updates the search index'
)

61
62
63
64
65
66
67
68
69
70
71
72
73
local -a _lib_arguments
_lib_arguments=(
    'create:Creates a new Pod'
    'lint:Validates a Pod'
)

local -a _plugins_arguments
_plugins_arguments=(
    'create:Creates a new plugin'
    'list:List all known plugins'
    'search:Search for known plugins'
)

Alexandre Joly's avatar
Alexandre Joly committed
74
75
76
77
78
local -a _list_arguments
_list_arguments=(
    'new:Lists pods introduced in the master spec-repo since the last check'
)

79
80
81
82
83
84
85
86
87
88
89
90
91
local -a _trunk_arguments
_trunk_arguments=(
    'add-owner:Add an owner to a pod'
    'me:Display information about your sessions'
    'push:Publish a podspec'
    'register:Manage sessions'
)

local -a _trunk_me_arguments
_trunk_me_arguments=(
    'clean-sessions:Remove sessions'
)

Alexandre Joly's avatar
Alexandre Joly committed
92
93
94
95
local -a _inherited_options
_inherited_options=(
    '(--silent)--silent[Show nothing]' \
    '(--verbose)--verbose[Show more debugging information]' \
96
    '(--no-ansi)--no-ansi[Show output without ANSI codes]' \
Alexandre Joly's avatar
Alexandre Joly committed
97
98
99
    '(--help)--help[Show help banner of specified command]'
)

100
101
102
103
104
105
106
local -a _root_options
_root_options=(
    '(--version)--version[Show the version of CocoaPods]' \
    '(--completion-script)--completion-script[Print the auto-completion script]'

)

Alexandre Joly's avatar
Alexandre Joly committed
107
108
109
110
111
112
113
local -a _install_options
_install_options=(
    '(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn` intact after downloading]' \
    '(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
    '(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
)

114
115
116
117
118
119
120
121
122
local -a _lib_lint_options
_lib_lint_options=(
    '(--quick)--quick[Lint skips checks that would require to download and build the spec]' \
    '(--only-errors)--only-errors[Lint validates even if warnings are present]' \
    '(--subspec=NAME)--subspec=[Lint validates only the given subspec]' \
    '(--no-subspecs)--no-subspecs[Lint skips validation of subspecs]' \
    '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]'
)

Alexandre Joly's avatar
Alexandre Joly committed
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
local -a _update_options
_update_options=(
    '(--no-clean)--no-clean[Leave SCM dirs like `.git` and `.svn intact after downloading]' \
    '(--no-integrate)--no-integrate[Skip integration of the Pods libraries in the Xcode project(s)]' \
    '(--no-repo-update)--no-repo-update[Skip running `pod repo update before install]'
)

local -a _outdated_options
_outdated_options=(
    '(--no-repo-update)--no-repo-update[Skip running `pod repo update` before install]'
)

local -a _search_options
_search_options=(
    '(--full)--full[Search by name, summary, and description]' \
    '(--stats)--stats[Show additional stats (like GitHub watchers and forks)]' \
    '(--ios)--ios[Restricts the search to Pods supported on iOS]' \
140
141
    '(--osx)--osx[Restricts the search to Pods supported on OS X]' \
    '(--web)--web[Searches on cocoapods.org]'
Alexandre Joly's avatar
Alexandre Joly committed
142
143
144
145
146
147
148
)

local -a _list_options
_list_options=(
    '(--update)--update[Run `pod repo update` before listing]'
)

149
150
151
local -a _plugins_search_options
_plugins_search_options=(
    '(--full)--full[Search by name, author, and description]'
Alexandre Joly's avatar
Alexandre Joly committed
152
153
)

154
155
local -a _repo_push_options
_repo_push_options=(
Alexandre Joly's avatar
Alexandre Joly committed
156
    '(--allow-warnings)--allow-warnings[Allows pushing even if there are warnings]' \
157
158
    '(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' \
    '*:script or directory:_files'
Alexandre Joly's avatar
Alexandre Joly committed
159
160
)

161
162
163
164
165
local -a _repo_add_options
_repo_add_options=(
    '(--shallow)--shallow[Create a shallow clone (fast clone, but no push capabilities)]'
)

Alexandre Joly's avatar
Alexandre Joly committed
166
167
168
169
170
171
172
local -a _repo_lint_options
_repo_lint_options=(
    '(--only-errors)--only-errors[Lint presents only the errors]'
)

local -a _setup_options
_setup_options=(
173
    '(--no-shallow)--no-shallow[Clone full history so push will work]'
Alexandre Joly's avatar
Alexandre Joly committed
174
175
176
177
178
179
180
    '(--push)--push[Use this option to enable push access once granted]'
)

local -a _spec_lint_options
_spec_lint_options=(
    '(--quick)--quick[Lint skips checks that would require to download and build the spec]' \
    '(--only-errors)--only-errors[Lint validates even if warnings are present]' \
181
182
    '(--subspec=NAME)--subspec=[Lint validates only the given subspec]' \
    '(--no-subspecs)--no-subspecs[Lint skips validation of subspecs]' \
183
184
    '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' \
    '*:script or directory:_files'
Alexandre Joly's avatar
Alexandre Joly committed
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
)

local -a _spec_cat_options
_spec_cat_options=(
    '(--show-all)--show-all[Pick from all versions of the given podspec]'
)

local -a _spec_which_options
_spec_which_options=(
    '(--show-all)--show-all[Print all versions of the given podspec]'
)

local -a _spec_edit_options
_spec_edit_options=(
    '(--show-all)--show-all[Pick which spec to edit from all available versions of the given podspec]'
)

202
203
204
205
206
local -a _trunk_register_options
_trunk_register_options=(
    '(--description=DESCRIPTION)--description=[An arbitrary description to easily identify your session later on.]'
)

Alexandre Joly's avatar
Alexandre Joly committed
207

Alexandre Joly's avatar
Alexandre Joly committed
208
209
210
211
212
__first_command_list ()
{
    local expl
    declare -a tasks

Alexandre Joly's avatar
Alexandre Joly committed
213
    tasks=(install ipc list outdated podfile-info push repo search setup spec update)
Alexandre Joly's avatar
Alexandre Joly committed
214
215
216
217
218

    _wanted tasks expl 'help' compadd $tasks
}

__repo_list() {
219
    _wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods/repos 2>/dev/null | sed -e 's/ /\\ /g')
Alexandre Joly's avatar
Alexandre Joly committed
220
221
222
223
224
225
226
227
228
229
}

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

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

Alexandre Joly's avatar
Alexandre Joly committed
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
    case $state in
        (command)
            _describe -t commands "pod repo" _repo_arguments
            return
        ;;

        (options)
            case $line[1] in
                (lint)
                    _arguments \
                        $_inherited_options \
                        $_repo_lint_options \
                        ':feature:__repo_list'
                ;;

                (update)
                    _arguments \
                        $_inherited_options \
                        ':feature:__repo_list'
                ;;

251
252
253
254
255
256
257
                (push)
                    _arguments \
                        $_inherited_options \
                        $_repo_push_options \
                        ':feature:__repo_list'
                ;;

Alexandre Joly's avatar
Alexandre Joly committed
258
259
                (add)
                    _arguments \
260
261
                        $_inherited_options \
                        $_repo_add_options
262
263
264
265
266
267

                (remove)
                    _arguments \
                        $_inherited_options \
                        ':feature:__repo_list'
                ;;
Alexandre Joly's avatar
Alexandre Joly committed
268
269
            esac
        ;;
Alexandre Joly's avatar
Alexandre Joly committed
270
271
272
273
274
275
    esac
}

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

Alexandre Joly's avatar
Alexandre Joly committed
277
    _arguments -C \
278
        $_inherited_options \
Alexandre Joly's avatar
Alexandre Joly committed
279
280
281
282
283
        ':command:->command' \
        '*::options:->options'

   case $state in
        (command)
Alexandre Joly's avatar
Alexandre Joly committed
284
            _describe -t commands "pod spec" _spec_arguments
Alexandre Joly's avatar
Alexandre Joly committed
285
286
287
288
            return
        ;;

        (options)
Alexandre Joly's avatar
Alexandre Joly committed
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
            case $line[1] in
                (create)
                    _arguments \
                        $_inherited_options
                ;;

                (lint)
                    _arguments \
                        $_inherited_options \
                        $_spec_lint_options
                ;;

                (cat)
                    _arguments \
                        $_inherited_options \
                        $_spec_cat_options
                ;;

                (which)
                    _arguments \
                        $_inherited_options \
                        $_spec_which_options
                ;;

                (edit)
                    _arguments \
                        $_inherited_options \
                        $_spec_edit_options
                ;;
            esac
Alexandre Joly's avatar
Alexandre Joly committed
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
            return
        ;;
    esac
}

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

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

   case $state in
        (command)
Alexandre Joly's avatar
Alexandre Joly committed
334
            _describe -t commands "pod ipc" _ipc_arguments
Alexandre Joly's avatar
Alexandre Joly committed
335
336
337
338
            return
        ;;

        (options)
Alexandre Joly's avatar
Alexandre Joly committed
339
340
            _arguments -C \
                $_inherited_options
Alexandre Joly's avatar
Alexandre Joly committed
341
342
343
344
345
            return
        ;;
    esac
}

346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
__pod-lib() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

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

   case $state in
        (command)
            _describe -t commands "pod lib" _lib_arguments
            return
        ;;

        (options)
            case $line[1] in
                (create)
                    _arguments \
                        $_inherited_options
                ;;

                (lint)
                    _arguments \
                        $_inherited_options \
                        $_lib_lint_options
                ;;
            esac
            return
        ;;
    esac
}

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

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

   case $state in
        (command)
            _describe -t commands "pod plugins" _plugins_arguments
            return
        ;;

        (options)
            case $line[1] in
                (create)
                    _arguments \
                        $_inherited_options
                ;;

                (list)
                    _arguments \
                        $_inherited_options
                ;;

                (search)
                    _arguments \
                        $_inherited_options \
                        $_plugins_search_options
                ;;
            esac
            return
        ;;
    esac
}

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

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

   case $state in
        (command)
            _describe -t commands "pod trunk" _trunk_arguments
            return
        ;;

        (options)
            case $line[1] in
                (add-owner)
                    _arguments \
                        $_inherited_options
                ;;

                (me)
                    __pod-trunk-me
                ;;

                (push)
                    _arguments \
                        $_inherited_options
                ;;

                (register)
                    _arguments \
                        $_inherited_options \
                        $_trunk_register_options
                ;;
            esac
            return
        ;;
    esac
}

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

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

   case $state in
        (command)
            _describe -t commands "pod trunk me" _trunk_me_arguments
            return
        ;;

        (options)
            case $line[1] in
                (clean-sessions)
                    _arguments \
                        $_inherited_options
                ;;
            esac
            return
        ;;
    esac
}

Alexandre Joly's avatar
Alexandre Joly committed
485
486
487
488
489
__pod-list() {
    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
Alexandre Joly's avatar
Alexandre Joly committed
490
491
        $_inherited_options \
        $_list_options \
Alexandre Joly's avatar
Alexandre Joly committed
492
493
494
495
496
        ':command:->command' \
        '*::options:->options'

   case $state in
        (command)
Alexandre Joly's avatar
Alexandre Joly committed
497
            _describe -t commands "pod list" _list_arguments
Alexandre Joly's avatar
Alexandre Joly committed
498
499
500
501
            return
        ;;

        (options)
Alexandre Joly's avatar
Alexandre Joly committed
502
503
504
            _arguments -C \
                $_inherited_options \
                $_list_options
Alexandre Joly's avatar
Alexandre Joly committed
505
506
507
508
509
            return
        ;;
    esac
}

Alexandre Joly's avatar
Alexandre Joly committed
510
511
512
513
local curcontext="$curcontext" state line
typeset -A opt_args

_arguments -C \
Alexandre Joly's avatar
Alexandre Joly committed
514
    $_inherited_options \
Alexandre Joly's avatar
Alexandre Joly committed
515
516
517
518
519
    ':command:->command' \
    '*::options:->options'

case $state in
  (command)
Alexandre Joly's avatar
Alexandre Joly committed
520
      _describe -t commands "pod" _1st_arguments
521
522
523
      _arguments \
            $_inherited_options \
            $_root_options
Alexandre Joly's avatar
Alexandre Joly committed
524
525
526
527
528
529
      return
  ;;

  (options)
    case $line[1] in
        (help)
Alexandre Joly's avatar
Alexandre Joly committed
530
531
532
            _arguments \
                $_inherited_options \
                ':help:__first_command_list'
Alexandre Joly's avatar
Alexandre Joly committed
533
534
        ;;

535
536
537
538
539
        (init)
            _arguments \
                $_inherited_options
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
540
        (push)
Alexandre Joly's avatar
Alexandre Joly committed
541
542
            _arguments \
                $_inherited_options \
543
                $_repo_push_options \
Alexandre Joly's avatar
Alexandre Joly committed
544
                ':repo:__repo_list'
Alexandre Joly's avatar
Alexandre Joly committed
545
546
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
547
548
549
550
551
552
553
554
555
556
557
558
        (repo)
            __pod-repo
        ;;

        (spec)
            __pod-spec
        ;;

        (ipc)
            __pod-ipc
        ;;

559
560
561
562
        (lib)
            __pod-lib
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
563
564
565
566
        (list)
            __pod-list
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
        (install)
            _arguments \
                $_inherited_options \
                $_install_options
        ;;

        (update)
            _arguments \
                $_inherited_options \
                $_update_options
        ;;

        (outdated)
            _arguments \
                $_inherited_options \
                $_outdated_options
        ;;

585
586
587
588
589
590
591
592
593
        (plugins)
            __pod-plugins
        ;;

        (trunk)
            __pod-trunk
        ;;

        (try)
Alexandre Joly's avatar
Alexandre Joly committed
594
            _arguments \
595
                $_inherited_options
Alexandre Joly's avatar
Alexandre Joly committed
596
597
        ;;

598
        (search)
Alexandre Joly's avatar
Alexandre Joly committed
599
600
            _arguments \
                $_inherited_options \
601
                $_search_options
Alexandre Joly's avatar
Alexandre Joly committed
602
603
604
605
606
607
608
609
        ;;

        (setup)
            _arguments \
                $_inherited_options \
                $_setup_options
        ;;

Alexandre Joly's avatar
Alexandre Joly committed
610
611
612
    esac
  ;;
esac