Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completions #773

Merged
merged 3 commits into from
Oct 24, 2016
Merged

Completions #773

merged 3 commits into from
Oct 24, 2016

Conversation

kbknapp
Copy link
Contributor

@kbknapp kbknapp commented Oct 24, 2016

This commit adds a command line option to generate completion scripts, as well as updates clap to 2.16.0 which adds ZSH completion support.

Here's a gif of the new ZSH support and the new rustup completions subcommand backing it.

rustup_zsh

Specifically this commit adds

$ rustup completions <shell>

Finally, this PR adds some additional help documentation on the completions command, and changes the README.md slightly to reflect the new additions.

Some notes about the ZSH script generated by clap, it supports, subcommands, flags, args, and options. The options also automatically list their possible_values, and will automatically not list any arguments they conflict with. This may not be too applicable to rustup since I don't think many of those options are used, but it's good to note for future reference.

Also, positional arguments, such as toolchain in a few of the subcommands is changed to uppercase ASCII by clap in order to differentiate.

Edit: removed verbiage about --completions

@Diggsey
Copy link
Contributor

Diggsey commented Oct 24, 2016

This is awesome 👍 My preference would be to stick with just rustup completions, since rustup self commands usually take the form rustup self <subcommand> <args...> rather than just rustup self <args...>

This commit adds two sections to the command line options to enable building of Shell Completion
Scripts to `stdout`. This allows these scripts to be redirected to a file, effectively allowing
the user to install these scripts at the location of their choosing.

The arguments only accept the values `zsh`, `fish` and `bash`, which clap guards against.

To use these scripts one must do one of the following

*Note:* The commands `rustup completions <SHELL>` and `rustup self --completions <SHELL>` are
synonyms for each other, and do the exact same thing.

```
$ rustup completions bash > /path/to/completions/dir/rustup.bash-completion
```

```
$ rustup completions fish > ~/.config/fish/completions/rustup.fish
```

```
$ mkdir ~/.zfunc
$ rustup completions zsh > ~/.zfunc/_rustup
$ echo "fpath+=~/.zfunc\ncominit" >> ~/.zshrc
$ exec zsh
```

Relates to rust-lang#278
@kbknapp
Copy link
Contributor Author

kbknapp commented Oct 24, 2016

That's a simple change - just let me know if you need me to change it, or any other aspects and I'd be happy to do so 😉

@brson
Copy link
Contributor

brson commented Oct 24, 2016

Pretty amazing @kbknapp. I agree with @Diggsey . Let's just have one way to do it.

@kbknapp
Copy link
Contributor Author

kbknapp commented Oct 24, 2016

I've removed the --completions arg. It's now just rustup completions <SHELL>

@brson brson merged commit ec46f9f into rust-lang:master Oct 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants