Add support for completion scripts #19

Merged
merged 3 commits into from May 8, 2014

Projects

None yet

6 participants

@fabiopelosin
Owner
Notes:
  • The script can be printed via the --completion-script flag. This flag is available only to the root command.
  • Dynamic generation of the completions, as they can change with plugins or new version of a tool, was inspected but the RubyGems overhead makes the process to0 slow (around 0.5s).
  • At the moment only support for Z shell is provided. Providing it for other shells should be reasonably easy now that the is an implementation but my shell-fu is very limited.
  • This approach is very fast.
  • Option completions are triggered only when the - character is typed, by zsh.
Possible future enhancements:
  • Some commands might still benefit from suggestions generated by the command line tool, for example pod search or pod lib lint.
Gif

2014-05-04 20_29_51

/c @alloy @Keithbsmiley @AliSoftware

Closes #11

Contributor

Woooow impressive!

wooow

Didn't know zsh completion system was so state-of-the-art compared to other shells, maybe I'll switch to it!

Owner

@irrationalfab I can't tell, but does the user have to do anything to enable autocomplete support here?

Member
keith commented May 4, 2014

Probably at least this:

autoload -Uz compinit
compinit -i
Owner

Bower now has an experimental completion command that is based on, and works similarly to the npm completion. It is not available for Windows users.

This command will output a Bash / ZSH script to put into your ~/.bashrc, ~/.bash_profile, or ~/.zshrc file.

bower completion >> ~/.bash_profile

From bower.io

I have it in a dedicated file which is in my fpath. Where https://github.com/sorin-ionescu/prezto stores the other auto completions.

Thinking about it we could store it in ./cocoapods and just setup to source that file. In that way we have full control to update it.

@orta
Owner
orta commented on 473baad May 5, 2014

well well well
this is certainly something I can get behind.

Owner

My current suggestion is:

$ echo $fpath # check that /usr/local/share/zsh/site-functions/ is included
$ rm -f /usr/local/share/zsh/site-functions/_pod && dpod --completion-script > /usr/local/share/zsh/site-functions/_pod && exec zsh

I'm wondering if pod setup could do this, automatically

Owner
alloy commented May 5, 2014

Groovy! 💃

Member
keith commented May 5, 2014

What if we did it like bower just with a suggestion for that? Since I'm sure some people will include it elsewhere, like in their dotfiles. I'm not sure if the duplicate thing would be an issue or just redundant.

Owner

I'm merging as the CocoaPods discussion is a separated one.

@fabiopelosin fabiopelosin merged commit 18bd7be into master May 8, 2014

1 check failed

continuous-integration/travis-ci The Travis CI build failed
Details
@fabiopelosin fabiopelosin deleted the irrtionalfab/completion branch May 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment