The following completion would happen (using example 17_yaml.rs):
```
$ prog <tab>
help subcmd
```
```
$ prog -<tab><tab>
--help -h (Prints help information)
--max-vals (you can only supply a max of 3 values for me!)
--min-vals (you must supply at least two values to satisfy me)
--mode (shows an option with specific values)
--mult-vals (demos an option which has two named values)
--option -o (example option argument from yaml)
--version -V (Prints version information)
-F (demo flag argument)
```
```
$ prog --<tab><tab>
--help -h (Prints help information)
--max-vals (you can only supply a max of 3 values for me!)
--min-vals (you must supply at least two values to satisfy me)
--mode (shows an option with specific values)
--mult-vals (demos an option which has two named values)
--option -o (example option argument from yaml)
--version -V (Prints version information)
```
```
$ prog --mode <tab>
emacs (shows an option with specific values) vi (shows an option with specific values)
```
```
$ prog subcmd -<tab>
--help -h (Prints help information) -B (example subcommand option)
--version -V (Prints version information)
```
```
$ prog subcmd --<tab>
--help (Prints help information) --version (Prints version information)
```
Close#578
* test: `require_unless_one` with second argument
Add the `require_unless_one_2` test. This tests that when the second
argument in the array is used at the command line, that the required
argument is not present. This test was added because it appears the
`require_unless_one` function only works for the first argument in the
array.
* Fix: assertions for test
The assertions did not check for the `infile` to be present.
add `gen_completions_to`
to write completions to buffer (e.g. stdout) instead of file. fixes#566
(for review; will fix commit message when done)
still pretty new to rust so comments on anything from style to structure would be must appreciated!
Fix the formatting in the completions example
A missing newline prevented the Cargo.toml excerpt in the `gen_completions` example from being properly formatted.
Aliases to subcommands can now be completed just like the original subcommand they alias.
Imagine a subcommand `update` with alias `install`, the `update` subcommand has an option `--pkg`
which accepts a package to update/install.
The following completion would happen:
```
$ prog <tab><tab>
-h --help -V --version install update
$ prog install <tab><tab>
-h --help -V --version --pkg
$ prog install --pkg <tab><tab>
$ prog install --pkg <PACKAGE>
$ prog update <tab><tab>
-h --help -V --version --pkg
$ prog update --pkg <tab><tab>
$ prog update --pkg <PACKAGE>
```
Closes#556
Prior to this change, completions only allowed one completion per command, this change allows as
many as required. The one downside to this change is the completion engine isn't smart enough to
determine which options are no longer legal after certain options have been applied.