Commit graph

6943 commits

Author SHA1 Message Date
Ed Page
125dbe0cfd
Merge pull request #4667 from corneliusroemer/fix-4666
fix: Add plural s to context in suggestions
2023-01-23 15:58:37 -06:00
Ed Page
401d86fb9c
Merge pull request #4668 from corneliusroemer/fix-4660
fix(suggestions): Replace wrong Jaro-Winkler
2023-01-23 15:55:59 -06:00
Cornelius Roemer
f5540d2646 fix(suggestions): Replace wrong Jaro-Winkler
Implementation of Jaro-Winkler similarity in the dguo/strsim-rs crate
is wrong, causing strings with common prefix >=10
to all be considered perfect matches

Using Jaro instead from the same crate fixes this issue
Benefit of favoring long prefixes exists for matching common names
But not for typo detection
Hence use of Jaro instead of Jaro-Winkler is acceptable

Confidence threshold adjusted so that `bar` is still suggested for `baz`
since Jaro is strictly < Jaro-Winkler
such an adjustment is expected. This is acceptable.
While exact suggestions may change, the net change will be positive
Suggestions are purely decorative and should thus not breaking change

Fixes #4660
Also see https://github.com/dguo/strsim-rs/issues/53
2023-01-23 22:43:48 +01:00
Cornelius Roemer
5dcc5c9509 fix: Add plural s in suggestions
Old: `note: subcommand 'test', 'temp' exist`
New: `note: subcommands 'test', 'temp' exist`
Fixes #4666
2023-01-23 22:16:50 +01:00
Ed Page
90c042eeae chore: Release 2023-01-23 13:05:20 -06:00
Ed Page
4f638b5c75 docs: Update changelog 2023-01-23 13:05:15 -06:00
Ed Page
930a40c1df
Merge pull request #4663 from fredrik-jansson-se/master
fix: Make cmd variable (bash completion) local
2023-01-23 13:04:09 -06:00
Fredrik Jansson
3426310d8e fix: Bash test cases 2023-01-23 19:20:09 +01:00
Fredrik Jansson
8b455d28e7 fix: Make cmd a local var in bash completion 2023-01-23 19:07:15 +01:00
Ed Page
3591dc7e84 test: Remove extraneous to_owned's 2023-01-23 10:33:47 -06:00
Ed Page
098a7007bb
Merge pull request #4664 from epage/suggest
test: Verify suggestions
2023-01-23 10:17:12 -06:00
Ed Page
cf970e6d0e test: Very best-fit for suggestions
Inspired by #4660
2023-01-23 09:58:03 -06:00
Ed Page
39fc252196 test: Re-enable suggestion tests 2023-01-23 09:55:14 -06:00
Ed Page
9f4f341604 chore: Release 2023-01-23 09:37:47 -06:00
Ed Page
faee38f59d docs: Update changelog 2023-01-23 09:37:06 -06:00
Ed Page
a493bb54f4
Merge pull request #4659 from epage/flag
docs: Prefer `get_flag` over `get_one::<bool>`
2023-01-23 09:36:21 -06:00
Ed Page
9d1de20787 docs: Prefer get_flag over get_one::<bool>
Inspired by #4654
2023-01-23 09:23:38 -06:00
Benjamin Gilbert
3755c56dcf fix(mangen): Avoid spurious value for derive arg
derive arguments like this:

    #[arg(long)]
    pub flag: bool,

were producing option descriptions like this:

    --flag=FLAG

FLAG is spurious.  It turns out that derive always sets a value name, for
simplicity, even when there are no arguments.  Check for this case.

Fixes #4443.
2023-01-16 12:04:43 -05:00
Ed Page
2a984ab777
Merge pull request #4640 from MariaSolOs/documentation-typo
docs: Typo in tab tag
2023-01-14 19:20:21 -06:00
Maria José Solano
bbf9b9c2f5
docs: Typo in tab tag 2023-01-14 13:05:17 -08:00
Ed Page
74a82d7085 chore: Release 2023-01-13 21:44:17 -06:00
Ed Page
06f392a0d2 docs: Update changelog 2023-01-13 21:44:12 -06:00
Ed Page
4d913fa4d1
Merge pull request #4639 from epage/error
fix(error): Try to soften unexpected argument/value errors
2023-01-13 21:42:45 -06:00
Ed Page
162a556dba fix(error): Try to soften unexpected argument/value errors
Adding "found" might seem minor but I feel it has a slight softening on the message.  It also maintains scanability as it is at the end and short.

As this is a one-off message change and not a styling issue to be consistent with, I think this is safe to put in a patch release.
2023-01-13 21:29:49 -06:00
Ed Page
34d856b449 chore: Release 2023-01-13 09:27:31 -06:00
Ed Page
889ca7a537 chore: Bump versions for 4.1 2023-01-13 09:24:37 -06:00
Ed Page
2bafb9b75d docs(contrib): Define a compatibility policy for help/error output 2023-01-13 07:19:30 -06:00
Ed Page
a41ca2edb0 docs: Update changelog 2023-01-13 07:13:28 -06:00
Ed Page
523adc20e7
Merge pull request #4635 from epage/stablize
feat: Stablize `ArgMatches::get_occurrences`
2023-01-13 06:52:30 -06:00
Ed Page
b4f111a978 feat: Stablize ArgMatches::get_occurrences
This let's you get an arguments values, grouped by the occurrence of the
argument.

Note: this does not stablize derive support.  That requires a blocking
change and can be enabled via `unstable-v5` flag.  See #4626 for an
exploration of how we can make this easier in the future.

Fixes #2924
2023-01-12 21:37:19 -06:00
Ed Page
72749a3a09
Merge pull request #4630 from eguiraud/patch-1
Prefer ok_or to ok_or_else in README example
2023-01-11 16:43:11 -06:00
Enrico Guiraud
84314614fb
docs: prefer ok_or to ok_or_else in README example
As suggested by clippy when using the example code.
2023-01-11 16:41:08 -06:00
Ed Page
37d03bb201
Merge pull request #4627 from tmccombs/macro-cleanup
refactor(derive): Clean up unnecessary noop parsing
2023-01-11 07:11:11 -06:00
Thayne McCombs
65f9e0d747 refactor(derive): Clean up unnecessary noop parsing
My guess is this was left over from switching to using the type based
API. The generated code for extracting values from `ArgMatches` had some
code that didn't actually do anything, like mapping over the identity
function, and wrapping a value in an `Ok` only to immediately use "?" on
it.
2023-01-11 01:38:36 -07:00
Ed Page
5345d6c332
Merge pull request #4625 from rhysd/fix-is-is
fix(doc): Fix typos in document of `ArgMatches` methods
2023-01-10 19:55:46 -06:00
rhysd
4b1f79b470 fix(doc): Fix typos in ArgMatches methods 2023-01-11 10:46:44 +09:00
David Aguilar
170bd59111 fix(complete): Handle multi-valued arguments
zsh completions for commands that have multiple Vec arguments require
special care.

We can have two Vec args separated with a value terminator.
We can also have two Vec args with no value terminators specified
where the final arg uses 'raw' and thus requires '--' to be used.

The 2nd of these scenarios requires special handling to avoid
emitting a duplicate '*:arguments' completion entry.

Currently, the zsh completions generate an error in this scenario:

    $ my-app <TAB>
    _arguments:...: doubled rest argument definition:
    *::second -- second set of of multi-length arguments:

We already use the '-S' option when calling _arguments.
This option makes it so that completion stops after '--' is encountered.
This means that the handling for trailing 'raw' arguments does not need
to specified.

Special-case multi-valued arguments so that we can skip emitting
the final multi-valued argument if a previous multi-valued argument
has already been emitted.

Closes #3022
Signed-off-by: David Aguilar <davvid@gmail.com>
2023-01-10 14:39:33 -08:00
Ed Page
b86c259ed0
Merge pull request #4624 from davvid/value-terminators
fix(completion): emit value terminators on zsh
2023-01-10 14:35:30 -06:00
Ed Page
e576c65dee style: Make clippy happy 2023-01-10 09:08:12 -06:00
Ed Page
084991f70a
Merge pull request #4600 from tmccombs/groups-derive
Add support for deriving grouped options for Vec<Vec<T>>
2023-01-10 08:43:36 -06:00
David Aguilar
58b0c504d8 fix(complete): Emit value terminators on zsh
Emit the user-defined value terminator into the zsh completion pattern
to avoid doubled rest-arguments definitions:

    $ my-app <TAB>
    _arguments:comparguments:325: doubled rest argument definition:
    *::second -- second set of of multi-length arguments:

https://github.com/clap-rs/clap/issues/3266#issuecomment-1007901407
noted that including the value terminator is one step towards a
robust solution for handling multiple multi-valued arguments.

This change does not yet handle automatically detecting when a value
terminator is needed, but it does add tests to ensure that
user-specified value terminators are used on zsh.

Related-to: #3022
Signed-off-by: David Aguilar <davvid@gmail.com>
2023-01-10 00:59:25 -08:00
David Aguilar
0b0306cc79 feat(api): Add Arg::get_value_terminator()
Expose get_value_terminator() for use by clap_complete.

Related-to: #3022
Signed-off-by: David Aguilar <davvid@gmail.com>
2023-01-10 00:38:56 -08:00
Ed Page
d0adade3dd
Merge pull request #4618 from epage/update
fix(derive): Allow update_from when explicit requireds used
2023-01-09 21:47:52 -06:00
Ed Page
50f033e6bc fix(derive): Allow users to override arg_required_else_help on sub-sub commands 2023-01-09 21:08:56 -06:00
Ed Page
af71ada3f4 fix(derive): Allow update_from when explicit requireds used
Fixes #4617
2023-01-09 20:52:46 -06:00
Ed Page
b9ae787d6b test(derive): Show update_from bug with explicit required 2023-01-09 20:52:45 -06:00
Ed Page
7b69dea24f test(derive): Unwrap, don't exit 2023-01-09 20:52:06 -06:00
Ed Page
9aa76fa12f docs: Update changelog 2023-01-09 14:03:47 -06:00
Ed Page
a2e8791bc4
Merge pull request #4615 from epage/MSRV
chore: Bump MSRV to 1.64.0
2023-01-09 13:55:48 -06:00
Ed Page
082d54a9dc style: Update for clippy 1.64 2023-01-09 12:38:55 -06:00