Commit graph

6635 commits

Author SHA1 Message Date
Ed Page
72469e7e54
Merge pull request #4298 from shellcodesniper/patch-1
doc(fix typo): no close bracket in example
2022-09-30 08:23:37 -05:00
Ed Page
2912a6436f chore: Release 2022-09-30 08:16:12 -05:00
Ed Page
b814c785ef docs(derive): Correct reference 2022-09-30 08:15:48 -05:00
KuuWang
71be5463e5
doc(fix typo): no close bracket in example
Tutorials (derive, builder > Tutorials (derive, builder)
2022-09-30 17:43:23 +09:00
Ed Page
5885cc7f0c
Merge pull request #4294 from epage/req
feat: Add ArgGroup::is_required_set
2022-09-29 16:49:13 -05:00
Ed Page
8fc8b5f273 feat: Add ArgGroup::is_required_set
This is a part of #4228

I thought I needed this for another change but it turned out I didn't.
2022-09-29 16:29:08 -05:00
Ed Page
eeafb2574b docs(complete): Don't use deprecated API 2022-09-29 16:11:03 -05:00
Ed Page
1e2b791049
Merge pull request #4292 from epage/func
refactor: Use getters internally
2022-09-29 15:50:51 -05:00
Ed Page
4634812e3d refactor: Use getters internally
This originally stemmed from wrapping `Arg` in a `Box`, but we had to
smash it with a hammer as it didn't improve things enough.

- This dropped binary size by 3-7 KiB
- Parsing slowed by 20%.
- Incremental rebuilds slowed down by 1%
2022-09-29 15:26:24 -05:00
Ed Page
84055f41e4 docs: Provide more nuance on allow_hyphen_values
This matches what we hope is the right behavior, see #4283
2022-09-29 14:41:39 -05:00
Ed Page
668c021419 chore: Release 2022-09-29 13:09:30 -05:00
Ed Page
9069755919 docs: Update changelog 2022-09-29 13:09:14 -05:00
Ed Page
d24e723bb4
Merge pull request #4255 from anshulrgoyal/master
[clap_mangen]fix: use proper sub-command name in manpages
2022-09-29 13:07:18 -05:00
Anshul Goyal
47790e62bf chore: Remove .vscode folder 2022-09-29 23:15:05 +05:30
Anshul Goyal
cdcf9aad34 fix: Add test for subcommand 2022-09-29 23:07:28 +05:30
Ed Page
80fb67edaa chore: Release 2022-09-29 12:08:47 -05:00
Ed Page
83db04c0c3 docs: Update changelog 2022-09-29 12:08:40 -05:00
Ed Page
cdaa8a18a5
Merge pull request #4289 from martinvonz/generate-subcommand-alias
Generate subcommand alias
2022-09-29 12:07:25 -05:00
Martin von Zweigbergk
33fa7c4c19 fix(complete): Fix command alias and Bash
With the previous fixes for #4273 and #4280 in place, it's now easy to
add support for subcommand aliases, which this commit does. This
addresses #4265 for Bash.
2022-09-29 08:58:32 -07:00
Martin von Zweigbergk
9ee45f7f3d fix(complete): Fix git diff log <TAB> for Bash
This continues the work started with the fix for #4273. There was
another bug caused by using the subcommand names without considering
their position in the argument list. If the user enters `git diff log
<TAB>`, we build up a string that identifies the subcommand. We ended
up making the string `git__diff__log` in this case because we appended
`__log` without considering the current state. Since `git__diff__log`
does not correspond to an actual command, we wouldn't provide any
suggestions.

This commit restructures the code so we walk subcommands and
subsubcommands in `bash.rs`. While walking those, we build up a list
containing triples of the parent `$cmd` name (e.g. `git__diff`), the
current command's name (e.g. `log`), and the `$cmd` for the current
command. We then build the shell script's case arms based on that
information.

We could instead have fixed #4280 by using the second element in the
pair returned from `utils::all_subcommands()` (a stringified list of
the subcommand path) instead of the first one. However, that would not
have helped us solve #4265.

Closes #4280
2022-09-29 08:58:32 -07:00
Martin von Zweigbergk
ea264fde16 fix(complete): Fix git diff git <TAB> for Bash
Early in the Bash-completion script, we build up a string that
identifies the command or subcommand. When we see the top-level
command's name (e.g. `git`) we set the command so far to that
value. We do that regardless of where in the argument list it
appears. For example, if the argument list is `git diff git`, we set
the current command to `git` when run into it the second time. We
therefore suggest arguments to the top-level command afterwards, which
is not correct.

This patch fixes that by also considering the string that identifies
the command so far, so we only set the overall command to `git` if the
command so far is the empty string.

This is actually just a step on the way to getting completion to work
for aliases of subcommands.

Closes #4273
2022-09-29 08:40:54 -07:00
Martin von Zweigbergk
35b5f9b276 refactor(complete): Remove an always-true check
The `text` variable here is clearly never empty, so don't check if it
is.
2022-09-29 08:40:54 -07:00
Martin von Zweigbergk
9c59c69bb0 refactor(complete): Remove unnecessary early return
There seems to be little reason to return early with an empty list
when there are no subcommands, instead of going through the loop 0
times and then returning the empty list.
2022-09-29 08:40:54 -07:00
Martin von Zweigbergk
8d0ef124e0 test(complete): Include a visible command alias
Only zsh includes completion for visible aliases of subcommands. Let's
show that in tests.
2022-09-29 08:40:54 -07:00
Martin von Zweigbergk
5020d739d5 refactor(complete): Add an alias for the subcommand
I want to add support for completion of arguments for aliased
subcommands so it's nice to have an example to test on.
2022-09-29 08:39:49 -07:00
Martin von Zweigbergk
6bc8d2632c refactor(complete): Add a subcommand to examples
It's useful when testing to have a subcommand in the examples.
2022-09-29 08:39:17 -07:00
Martin von Zweigbergk
8b33da3138 fix(complete): Make the two examples consistent
The derive-based example has a `///` comment on one argument, which
ends up as a description for the argument in the generated completion
scripts. Let's switch to `//` so the two scripts produce the same
output (except for the binary name), so they're easy to compare.
2022-09-29 08:37:03 -07:00
Martin von Zweigbergk
59270b1c81 fix(complete): Make example commands match binary
The example binaries were renamed in 89c2b3bb0d, but the commands in
them were not, making the generated completion scripts not work
(because we use the command name as binary name in the examples).
2022-09-29 08:34:19 -07:00
Ed Page
9f30493e5f chore: Release 2022-09-29 10:08:12 -05:00
Ed Page
5cab144f72 docs: Update changelog 2022-09-29 10:08:04 -05:00
Ed Page
7ea950a9ae
Merge pull request #4288 from epage/conflict
fix(error): Specialize the self-conflicts error
2022-09-29 10:07:26 -05:00
Ed Page
4e9f3cca2c fix(error): Specialize the self-conflicts error
Inspired by rust-lang/cargo#11159
2022-09-29 09:54:20 -05:00
Ed Page
2c097814e4 test(error): Self-conflict 2022-09-29 09:43:33 -05:00
Ed Page
337a9e089b chore: Release 2022-09-29 09:27:13 -05:00
Ed Page
d25d5b696d docs: Update changelog 2022-09-29 09:27:06 -05:00
Ed Page
2583b8473d
Merge pull request #4287 from epage/usage
fix(error): Polish up errors a little
2022-09-29 09:23:27 -05:00
Ed Page
1a8ffc2a78 docs: Clarify support policy 2022-09-29 09:06:31 -05:00
Ed Page
5399f49572 fix(error): Quote literals consistently 2022-09-29 08:54:03 -05:00
Ed Page
2d86f96d64 fix(error): Stylize escape suggestions 2022-09-29 08:47:56 -05:00
Ed Page
549911a84a fix(error): Format help suggestion as literal 2022-09-29 08:43:05 -05:00
Ed Page
4524127704 chore: Release 2022-09-28 17:02:08 -05:00
Ed Page
d279f7f4e6 docs: Update changelog 2022-09-28 17:01:56 -05:00
Ed Page
929c87c5b8
Merge pull request #4281 from epage/override
fix(parser): Allow one-off self-overrides
2022-09-28 17:00:55 -05:00
Ed Page
3683e2c791 fix(parser): Allow one-off self-overrides
bat needed this.

See also #4261
2022-09-28 16:45:35 -05:00
Ed Page
2d7874948f fix(parser): SetFalse should also not allow self-override 2022-09-28 16:26:36 -05:00
Ed Page
bf42ff04d5 chore: Release 2022-09-28 15:34:33 -05:00
Ed Page
824f6589ad docs: Update changelog 2022-09-28 15:34:25 -05:00
Ed Page
7b886d2c63
Merge pull request #4278 from intgr/zsh-completion-fix-multiple-args-handling
fix(complete): Fix zsh handling of multiple arguments
2022-09-28 15:33:42 -05:00
Marti Raudsepp
89cae3a2b3 fix(complete): Fix handling of multiple arguments 2022-09-28 23:02:31 +03:00
Ed Page
f6602c573c chore: Release 2022-09-28 14:51:22 -05:00