From c26facb582eed3b63642665864258862aa49392b Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Fri, 5 Jul 2013 00:58:05 +0200 Subject: [PATCH 1/7] first few lines for the autocompletion of cocoapods --- plugins/pod/_pod | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 plugins/pod/_pod diff --git a/plugins/pod/_pod b/plugins/pod/_pod new file mode 100644 index 000000000..2c183635d --- /dev/null +++ b/plugins/pod/_pod @@ -0,0 +1,82 @@ +#compdef pod + +# ----------------------------------------------------------------------------- +# FILE: pod.plugin.zsh +# DESCRIPTION: Cocoapods autocomplete plugin for Oh-My-Zsh +# AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch) +# GITHUB: https://github.com/mekanics +# VERSION: 0.0.1 +# ----------------------------------------------------------------------------- + +_pod_all_repos() { + repos=(`ls ~/.cocoapods`) +} + +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' +) + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "pod command" _1st_arguments + return +fi + +local -a _command_args +case "$words[1]" in + install) + _command_args=( + '(--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]' + ) + ;; + update) + _command_args=( + '(--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]' + ) + ;; + outdated) + _command_args=( + '(--no-repo-update)--no-repo-update[Skip running `pod repo update before install]' + ) + ;; + search) + _command_args=( + '(--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]' \ + '(--osx)--osx[Restricts the search to Pods supported on OS X]' + ) + ;; + update) + _command_args=( + '(--update)--update[Run `pod repo update before listing]' + ) + ;; +esac + +_arguments \ + $_command_args \ + '(--silent)--silent[Show nothing]' \ + '(--version)--version[Show the version of CocoaPods]' \ + '(--no-color)--no-color[Show output without color]' \ + '(--verbose)--verbose[Show more debugging information]' \ + '(--help)--help[Show help banner of specified command]' \ + && return 0 \ No newline at end of file From cf5ca2f4f3e6d98a4d4d4938be0e421645722fb2 Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Fri, 5 Jul 2013 11:07:29 +0200 Subject: [PATCH 2/7] commands and subcommands --- plugins/pod/_pod | 219 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 168 insertions(+), 51 deletions(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index 2c183635d..ce8882d42 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -1,16 +1,29 @@ #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 # ----------------------------------------------------------------------------- -_pod_all_repos() { - repos=(`ls ~/.cocoapods`) -} +#------------------ +# TODO: +# - Parameters for +# - install +# - update +# - outdated +# - search +# - list +# - push +# - podfile-info +# - setup +#------------------ local -a _1st_arguments _1st_arguments=( @@ -29,54 +42,158 @@ _1st_arguments=( 'update:Update outdated project dependencies' ) -_arguments '*:: :->command' +local -a _repo_arguments +_repo_arguments=( + 'add:Add a spec repo' + 'lint:Validates all specs in a repo' + 'update:Update a spec repo' +) -if (( CURRENT == 1 )); then - _describe -t commands "pod command" _1st_arguments - return -fi +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 _command_args -case "$words[1]" in - install) - _command_args=( - '(--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]' - ) - ;; - update) - _command_args=( - '(--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]' - ) - ;; - outdated) - _command_args=( - '(--no-repo-update)--no-repo-update[Skip running `pod repo update before install]' - ) - ;; - search) - _command_args=( - '(--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]' \ - '(--osx)--osx[Restricts the search to Pods supported on OS X]' - ) - ;; - update) - _command_args=( - '(--update)--update[Run `pod repo update before listing]' - ) - ;; +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 - -_arguments \ - $_command_args \ - '(--silent)--silent[Show nothing]' \ - '(--version)--version[Show the version of CocoaPods]' \ - '(--no-color)--no-color[Show output without color]' \ - '(--verbose)--verbose[Show more debugging information]' \ - '(--help)--help[Show help banner of specified command]' \ - && return 0 \ No newline at end of file From 1d636fe8ab4a7258eddbe120d462cdda3d8adbaf Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Fri, 5 Jul 2013 11:17:33 +0200 Subject: [PATCH 3/7] pod-list pod-lib removed. whyever I described it... --- plugins/pod/_pod | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index ce8882d42..1decb8872 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -30,7 +30,6 @@ _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' @@ -77,7 +76,7 @@ __first_command_list () local expl declare -a tasks - tasks=(install ipc lib list outdated podfile-info push repo search setup spec update) + tasks=(install ipc list outdated podfile-info push repo search setup spec update) _wanted tasks expl 'help' compadd $tasks } @@ -152,6 +151,27 @@ __pod-ipc() { esac } +__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 +} + local expl @@ -192,7 +212,7 @@ case $state in __pod-list ;; - (install|lib|outdated|podfile-info|push|search|setup|update) + (install|outdated|podfile-info|push|search|setup|update) #_arguments ':feature:__repo_list' esac ;; From c48822b3a3a3f25922c184d1804fc11aea2b6432 Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Fri, 5 Jul 2013 11:28:00 +0200 Subject: [PATCH 4/7] show repos on pod push --- plugins/pod/_pod | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index 1decb8872..78644745b 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -196,6 +196,10 @@ case $state in _arguments ':feature:__first_command_list' ;; + (push) + _arguments ':feature:__repo_list' + ;; + (repo) __pod-repo ;; @@ -212,7 +216,7 @@ case $state in __pod-list ;; - (install|outdated|podfile-info|push|search|setup|update) + (install|outdated|podfile-info|search|setup|update) #_arguments ':feature:__repo_list' esac ;; From 0892bce00b73fdf75d70e554b1fd64ae0fd5e61a Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Tue, 9 Jul 2013 14:41:41 +0200 Subject: [PATCH 5/7] supplemented with options --- plugins/pod/_pod | 239 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 197 insertions(+), 42 deletions(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index 78644745b..bb4f782b3 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -12,19 +12,6 @@ # 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.' @@ -71,6 +58,92 @@ _list_arguments=( 'new:Lists pods introduced in the master spec-repo since the last check' ) +local -a _inherited_options +_inherited_options=( + '(--silent)--silent[Show nothing]' \ + '(--version)--version[Show the version of CocoaPods]' \ + '(--no-color)--no-color[Show output without color]' \ + '(--verbose)--verbose[Show more debugging information]' \ + '(--help)--help[Show help banner of specified command]' +) + +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]' +) + +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]' \ + '(--osx)--osx[Restricts the search to Pods supported on OS X]' +) + +local -a _list_options +_list_options=( + '(--update)--update[Run `pod repo update` before listing]' +) + +local -a _podfile_info_options +_podfile_info_options=( + '(--all)--all[Show information about all Pods with dependencies that are used in a project]' \ + '(--md)--md[Output information in Markdown format]' +) + +local -a _push_options +_push_options=( + '(--allow-warnings)--allow-warnings[Allows pushing even if there are warnings]' \ + '(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' +) + +local -a _repo_lint_options +_repo_lint_options=( + '(--only-errors)--only-errors[Lint presents only the errors]' +) + +local -a _setup_options +_setup_options=( + '(--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]' \ + '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' +) + +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]' +) + + __first_command_list () { local expl @@ -82,7 +155,7 @@ __first_command_list () } __repo_list() { - _wanted application expl 'command' compadd $(command ls -1 ~/.cocoapods 2>/dev/null | sed -e 's/ /\\ /g') + _wanted application expl 'repo' compadd $(command ls -1 ~/.cocoapods 2>/dev/null | sed -e 's/ /\\ /g') } __pod-repo() { @@ -93,19 +166,32 @@ __pod-repo() { ':command:->command' \ '*::options:->options' - case $state in - (command) - _describe -t commands "gem subcommand" _repo_arguments - return - ;; + case $state in + (command) + _describe -t commands "pod repo" _repo_arguments + return + ;; - (options) - case $line[1] in - (update|lint) - _arguments ':feature:__repo_list' - ;; - esac - ;; + (options) + case $line[1] in + (lint) + _arguments \ + $_inherited_options \ + $_repo_lint_options \ + ':feature:__repo_list' + ;; + + (update) + _arguments \ + $_inherited_options \ + ':feature:__repo_list' + ;; + + (add) + _arguments \ + $_inherited_options + esac + ;; esac } @@ -119,12 +205,41 @@ __pod-spec() { case $state in (command) - _describe -t commands "gem subcommand" _spec_arguments + _describe -t commands "pod spec" _spec_arguments return ;; (options) - #todo + 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 return ;; esac @@ -140,12 +255,13 @@ __pod-ipc() { case $state in (command) - _describe -t commands "gem subcommand" _ipc_arguments + _describe -t commands "pod ipc" _ipc_arguments return ;; (options) - #todo + _arguments -C \ + $_inherited_options return ;; esac @@ -156,48 +272,53 @@ __pod-list() { typeset -A opt_args _arguments -C \ + $_inherited_options \ + $_list_options \ ':command:->command' \ '*::options:->options' case $state in (command) - _describe -t commands "gem subcommand" _list_arguments + _describe -t commands "pod list" _list_arguments return ;; (options) - #todo + _arguments -C \ + $_inherited_options \ + $_list_options return ;; esac } - - -local expl -#local -a boxes installed_boxes - local curcontext="$curcontext" state line typeset -A opt_args _arguments -C \ + $_inherited_options \ ':command:->command' \ '*::options:->options' case $state in (command) - _describe -t commands "gem subcommand" _1st_arguments + _describe -t commands "pod" _1st_arguments return ;; (options) case $line[1] in (help) - _arguments ':feature:__first_command_list' + _arguments \ + $_inherited_options \ + ':help:__first_command_list' ;; (push) - _arguments ':feature:__repo_list' + _arguments \ + $_inherited_options \ + $_push_options \ + ':repo:__repo_list' ;; (repo) @@ -216,8 +337,42 @@ case $state in __pod-list ;; - (install|outdated|podfile-info|search|setup|update) - #_arguments ':feature:__repo_list' + (install) + _arguments \ + $_inherited_options \ + $_install_options + ;; + + (update) + _arguments \ + $_inherited_options \ + $_update_options + ;; + + (outdated) + _arguments \ + $_inherited_options \ + $_outdated_options + ;; + + (search) + _arguments \ + $_inherited_options \ + $_search_options + ;; + + (podfile-info) + _arguments \ + $_inherited_options \ + $_podfile_info_options + ;; + + (setup) + _arguments \ + $_inherited_options \ + $_setup_options + ;; + esac ;; esac From 45314ee5b7ad2d7daafe940b801ddacd151d7017 Mon Sep 17 00:00:00 2001 From: mekanics Date: Wed, 10 Jul 2013 00:14:08 +0200 Subject: [PATCH 6/7] correct filename in the comments --- plugins/pod/_pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index bb4f782b3..c1eb86b5e 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -2,7 +2,7 @@ #autoload # ----------------------------------------------------------------------------- -# FILE: pod.plugin.zsh +# FILE: _pod # DESCRIPTION: Cocoapods autocomplete plugin for Oh-My-Zsh # http://cocoapods.org # AUTHOR: Alexandre Joly (alexandre.joly@mekanics.ch) From ba7fe6df62236dfa03a360a8707ebd0c0b1a645a Mon Sep 17 00:00:00 2001 From: Alexandre Joly Date: Mon, 15 Jul 2013 14:37:31 +0200 Subject: [PATCH 7/7] show file liste on 'pod push [REPO]' and tab, 'pod spec lint' and 'pod podfile-info' --- plugins/pod/_pod | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/pod/_pod b/plugins/pod/_pod index c1eb86b5e..563fa5e66 100644 --- a/plugins/pod/_pod +++ b/plugins/pod/_pod @@ -102,13 +102,15 @@ _list_options=( local -a _podfile_info_options _podfile_info_options=( '(--all)--all[Show information about all Pods with dependencies that are used in a project]' \ - '(--md)--md[Output information in Markdown format]' + '(--md)--md[Output information in Markdown format]' \ + '*:script or directory:_files' ) local -a _push_options _push_options=( '(--allow-warnings)--allow-warnings[Allows pushing even if there are warnings]' \ - '(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' + '(--local-only)--local-only[Does not perform the step of pushing REPO to its remote]' \ + '*:script or directory:_files' ) local -a _repo_lint_options @@ -125,7 +127,8 @@ 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]' \ - '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' + '(--no-clean)--no-clean[Lint leaves the build directory intact for inspection]' \ + '*:script or directory:_files' ) local -a _spec_cat_options