Commit graph

24 commits

Author SHA1 Message Date
Kurt Wolf
a9f4d759c0 Allow bash completions to work with an alias (clap-rs/clap#2054) 2021-11-29 09:02:52 -06:00
Ed Page
7e899cd340 Revert "Deprecate Arg::help in favour of Arg::about"
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840

This is part of #16.  clap-rs/clap#1840 wasn't the right call but we
don't have time to make the decision now, so instead of having one
option and changing it in 4.0, this reverts back to clap2 behavior.
2021-11-18 12:25:49 -06:00
rhysd
012f318c97 feat(doc): Fix many typos in docs, comments and codes found by typos-cli 2021-10-19 10:38:22 +09:00
Ajeet D'Souza
cad1879ab2 Improve bash generator 2021-10-14 22:51:40 +01:00
Nicolas Stinus
de1c764905 fix(gen): in bash, pass use possible_values if available
Change-Id: I7a54821666f0ba366379d6cac83898fcd9b76ee6
2021-10-14 14:41:11 -04:00
Ed Page
a61b60816c fix(gen): Ensure subcommands are post-processed
`App::get_matches` lazily post-processes `App`s and `Arg`s so we don't
do it to subcommands that are never run (downside being people have to
exercise their full app to get debug_asserts).

`clap_generate` was only post-processing the top-level `App` and `Arg`s,
ignoring the sub-commands.  In #2858, we noticed that `--version` was
being left in the completions instead of being removed during the
`_build` step.  We would also have an incorrect `num_vals` and a host of
other problems.

This change adds a `App::_build_all` function for `clap_generate` to use
to eagerly build everything.  By having it there, we make sure
everywhere that needs eager building, gets it (like some tests).

In `clap_generate::utils`, we add a unit test to ensure the subcommand's
`--version` was removed.

For some other tests specifying `.version()`, I added
`AppSettings::PropagateVersion` to make it behave more consistently.
The places I didn't were generally where the version was conditionally
set.

For `clap_generate/tests/generate_completions.rs`, I had to adjust the
`conflicts_with` because the subcommand was inheriting the argument with
it defined *but* the subcommand did not have the argument, tripping up a
debug assert.

Fixes #2860
2021-10-12 15:54:26 -05:00
Paul Seyfert
25e337adb1 [clap_generate] [zsh] sort out multiple occurrence vs multiple_value. 2021-10-12 10:48:37 +01:00
Pavan Kumar Sunkara
0a61c8aa08 fix: Whitespace in our generators **is** important and we need to fix it 2021-10-12 02:08:11 +01:00
Ed Page
1bbfd956aa test: Harden tests against trailing whitespace
In a follow up commit, my editor stripped trailing whitespace.  Rather
than have everyone fight this, let's not make a deal over the small
stuff.
2021-10-11 10:44:48 -05:00
Kevin K
14c8850019
tests: fixes test to new default behavior
This commit corrects tests to not expect the `-V,--version` flag when no
version information has been provided.
2021-10-09 11:12:50 -04:00
cherryblossom
f77dceaf69
Fix Elvish completions generation
The `display-suffix` option for `edit:complex-candidate` was [deprecated in Elvish v0.14.0][1] and
removed in v0.15.0 (latest version is v0.16.3), so this commit changes the Elvish completions
generation to use the `display` option instead.

Additionally, this commit changes assignments to use the `var` and `set` keywords as using
`name = value` without these keywords ('legacy assignment form') [will be deprecated][2].

[1]: https://elv.sh/blog/0.14.0-release-notes.html
[2]: https://elv.sh/ref/language.html#legacy-assignment-form
2021-09-24 22:29:05 +10:00
Roland Fredenhagen
0105e6f0b8
fix(generate): Better subcommand completion in fish (#2726)
* fix(generate): Better subcommand completion in fish

* Prevent completing subcommands that were already completed

* Make sure all parent subcommands actually existent

Partially fixes #2715

* Added Test

* fix(generate) Improve subcommand testing

This now also disables the completion of sub_subcommands options for
subcommands.
2021-09-08 15:32:26 +01:00
patrick-gu
a4dc72ed19 Replace "Prints" with "Print" for default help and version commands 2021-07-29 20:23:25 -07:00
Ajeet D'Souza
401744e24b Remove old slice syntax 2021-04-08 17:10:17 +05:30
Ajeet D'Souza
34fb411965 Use str:has-prefix in place of has-prefix 2021-04-08 16:51:06 +05:30
Jan Verbeek
7bb2795706 fix: Do not look for subcommands in fish completion if none exist 2021-02-22 15:35:07 +01:00
Logan SQUIREL
f74af655ce
Apply @pksunkara review 2021-02-22 09:37:29 +01:00
Logan SQUIREL
22b5d34693
imp: Visible aliases for arguments in completions (#2335)
Following changes are implemented:

- Add 'clap::Arg::get_visible_aliases(&self)' method
  This new method provides access to visible argument aliases
- Add 'clap::Arg::get_short/long_and_visible_aliases
  This new method provides access to the short/long arguments and its
  visible aliases
- Add visible aliases completions in clap_generate for following shells:
  - Bash
  - Elvish
  - Fish
  - Powershell
  - Zsh
- Add test fixtures for testing visible alias completions in clap_generate:
  'clap_generate/tests/completions/<shell>::<shell>_with_aliases()'
2021-02-22 09:36:08 +01:00
Pavan Kumar Sunkara
c9cb22905c Build help and version args at the beginning 2021-02-07 14:46:38 +00:00
Arne Beer
f290a9de72 Code formatting and completion script formatting 2020-12-28 01:41:57 +01:00
Arne Beer
915d60504c zsh: Test subcommand help text escaping 2020-12-28 01:41:57 +01:00
Arne Beer
9001bf5d21 zsh: Fix subcommand help escaping 2020-12-28 01:41:57 +01:00
Arne Beer
84d99d6bb8 Give each shell test their own App
Right now, adjusting test cases to cover some special edge-cases for a
specific shell is a little problematic.

For instance, if you add a special character that needs escaping
to one of the help strings, not only the tests for the shell you're
currently working on need adjustments, but rather all shell tests!

Contributors can often only work on one specific shell. The
need to adjust shells they don't know anything about discourages
testing or makes it simply impossible for a single contributor.

Arguably, this commit introduces a lot of code duplication, but on
the other hand it also makes testing a lot easier.
2020-12-28 01:40:15 +01:00
Arne Beer
6f930379cc Put completion tests for different shells in submodules 2020-12-27 20:47:30 +01:00