Commit graph

244 commits

Author SHA1 Message Date
Ed Page
cf151fd46b
Merge pull request #5542 from casey/exit-without-flushing
Exit without flushing stdout and stderr
2024-06-21 12:45:51 -05:00
Casey Rodarmor
90b2661ad0 fix: Exit without flushing stdout and stderr
Standard out is flushed during `std::rt::cleanup()`, called by
`std::process::exit()`, and standard error is unbuffered, so doesn't
need to be flushed.
2024-06-19 21:19:32 -07:00
rustco
462c5ada4a chore: fix some comments
Signed-off-by: rustco <ruster@111.com>
2024-06-20 11:40:13 +08:00
Ed Page
b3effeae10 style: Make clippy happy 2024-06-13 12:45:33 -05:00
Ed Page
6c6839a454 chore: Release 2024-06-10 09:30:20 -05:00
Ed Page
cf5c95862e fix(parser): Report correct num_args on too-few
Fixes #5526
2024-06-10 09:16:53 -05:00
Ed Page
122a2b3b8a chore: Release 2024-06-06 16:36:35 -05:00
Ed Page
d87dee6d48
Merge pull request #5476 from pzmarzly/issue-4265
feat(complete): generate completions for visible aliases
2024-06-06 16:33:01 -05:00
Ed Page
f087c39884 chore: Release 2024-06-06 15:14:24 -05:00
Ed Page
08656d046e fix(parser): Allow exclusive to override required_*
There are other cases for `required` that aren't being handled
- Groups
- Conflicts

I'm concerned there might be weird corner cases and didn't want the
analysis for that to block fixing this.

Fixes #5507
2024-06-06 15:01:04 -05:00
Ed Page
5e3386bb40 docs: Link to repo, not webpage inside repo 2024-06-04 15:36:17 -05:00
Ed Page
4aefa3c1c7 docs(ref): Clean up long help descriptions 2024-05-20 16:09:03 -05:00
Ed Page
d408a823a6
Merge pull request #5491 from pgerber/doc
Fix documentation for Command::after_long_help()
2024-05-20 16:05:08 -05:00
Peter Gerber
659e936a02
docs: Fix documentation for Command::*long_*()
long_help() does not propagate the message to help(). Nor do the
others.
2024-05-20 20:47:01 +00:00
Pawel Zmarzly
5000d58f38 feat(complete): Add autocomplete for visible_alias
Let's generate autocompletions for aliased subcommands.

    $ source before.zsh
    $ clap-test [TAB] <- gives me "foo bar --"
    $ clap-test foo [TAB] <- gives me "--my-flag"
    $ clap-test bar [TAB] <- no reaction

    $ source after.zsh
    $ clap-test [TAB] <- gives me "foo bar --"
    $ clap-test foo [TAB] <- gives me "--my-flag"
    $ clap-test bar [TAB] <- gives me "--my-flag"
2024-05-17 15:17:44 +01:00
Ed Page
958c749e61 style: Make clippy happy 2024-05-14 14:06:10 -05:00
Ed Page
22148eb87d fix(help): Take long_help into account for next_line_help detection 2024-05-14 13:53:17 -05:00
Ed Page
800d7cb8ad chore: Update from template 2024-05-14 12:27:02 -05:00
Ed Page
7d3a380b3d docs(ref): Clean up default_missing_value grammar 2024-05-03 10:59:45 -05:00
Ed Page
11ff6ccb0d docs(ref): Clarify Count starts from 0 2024-05-03 10:59:45 -05:00
renovate[bot]
24651fcfef
chore(deps): update compatible (dev) (#5477)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-05-01 01:04:57 +00:00
Will-Low
41c0d514bc Update doctring for BoolishValueParser::new 2024-04-23 12:14:42 -07:00
Ed Page
93d40450f7 docs: Fix typo 2024-04-09 12:05:12 -05:00
Ed Page
f65d421607 chore: Release 2024-03-06 10:52:18 -06:00
Amaan Qureshi
2aea9504c4
fix: Use SCREAMING_SNAKE_CASE for static variable authors 2024-03-05 23:52:48 -05:00
Ben Wiederhake
0076cac7cb fix(builder): Don't doc-link to undocumented item 2024-02-23 01:40:29 +01:00
Ed Page
8a7a13a561 chore: Release 2024-02-16 07:08:54 -06:00
Ed Page
446328a8d3 fix(error): Include -- in more cases
Inspired by rust-lang/cargo#12494.
Part of this is that our "did you mean" does prefix checks so it can be
overly aggressive in providing suggestions.
To avoid providing needless suggestions I limited this change to `last`
/ `trailing_var_arg` as those convey that `--` is more likely a valid
suggestion.
2024-02-16 06:54:57 -06:00
Ed Page
323345b3bc fix: Add missing clap::builder::OsStr impl
Found via rust-lang/cargo#10554
2024-02-10 19:59:40 -06:00
Ed Page
a751c5fe65 chore: Release 2024-02-08 10:34:06 -06:00
Ed Page
9ec6c942b8 chore: Release 2024-02-08 10:33:13 -06:00
renovate[bot]
cd0ca3cc13 chore(deps): update rust crate strsim to 0.11.0 2024-02-01 01:06:03 +00:00
Ed Page
0134f45ff0 chore: Release 2024-01-16 14:28:07 -06:00
Ed Page
2f1890907e
Merge pull request #5314 from epage/required
fix(parser): Don't duplicate requireds when usage disabled
2024-01-16 14:26:40 -06:00
Ed Page
0a635b9a20 fix(parser): Don't duplicate requireds when usage disabled
Skipping a test for now because we don't have a mixed-feature testing
strategy.

Fixes #5312
2024-01-16 14:15:48 -06:00
Martin Pool
8c83971b8c
docs: Link to exit code info 2024-01-15 14:30:11 -08:00
Ed Page
ef98da27cb chore: Release 2024-01-15 10:20:03 -06:00
Ed Page
50c59f63bb fix(parser): Don't panic with conflicts and groups
With #5298, I had overlooked that `matcher.arg_ids()` includes
`ArgGroup`s.  I had assumed I could always find a present `id` among
`Arg`s and `unwrap`ed.

I skipped a test for this because the use case is a bit strange that the
long term value for the test would likely be low.
If/when we add derive support for `args_conflicts_with_subcommands`, it
will then cover this case.

Fixes #5304
2024-01-15 09:30:19 -06:00
Ed Page
cbc9c9dd44 chore: Release 2024-01-11 20:52:38 -06:00
Ed Page
2a3356a535 fix: Update anstream 2024-01-11 20:33:39 -06:00
Ed Page
12b5c39d46 chore: Release 2024-01-11 10:37:53 -06:00
Ed Page
f529ec398c fix(parser): Ensure subcommand flags can conflict
Fixes #5297
2024-01-11 10:25:57 -06:00
Ed Page
a7e04a53e4 fix(parser): Improve subcommand conflict error 2024-01-11 10:20:19 -06:00
Ed Page
ea00ef3051 refactor(error): Allow more conflict sources 2024-01-11 10:17:35 -06:00
Ed Page
e47d8a2a66 refactor(parser): Clarify arg error 2024-01-11 09:47:00 -06:00
Ed Page
514f28bc92 chore: Release 2024-01-08 10:39:47 -06:00
Ed Page
3eaf1af052 fix(help): Correctly show help for fake flags 2024-01-08 09:58:42 -06:00
Ed Page
148e102ac3 fix(builder): Allow custom flag definitions
The goal is to allow getting the position of repeated flags for #5287
2024-01-08 09:49:43 -06:00
Ed Page
6d601e6f31 chore: Release 2023-12-28 12:07:48 -06:00
Sean Allred
05cd057978
perf: Avoid retrieving possible_values unless used
In some sophisticated situations, these may be expensive to calculate.
One example might be a '--branch' option accepting any single Git
branch that exists on the remote -- in such a case, the remote would
need to be queried for all possible_values. The cost is ultimately
unavoidable at runtime since this validation has to happen eventually,
but there's no need to pay it when generating help text if
`is_hide_possible_values_set`.

To keep '-h' fast, avoid collecting `possible_values` during '-h'
unless we're actually going to use the values in display.

This optimization is repeated for the manpage renderer.

This is trivially based on the short-circuiting logic at [1], which at
least supports the idea that actually consuming the iterator is not
generally-guaranteed behavior when `hide_possible_values` is set.

Note on the 'expensive' mod: This keeps all the possible_values tests
in one file but allows the entire set of tests to be controlled by the
'strings' feature (which is required to be able to use String rather
than str for each possible value).

[1]: clap_builder/src/builder/command.rs:long_help_exists_
2023-12-28 10:06:35 -06:00