Commit graph

6391 commits

Author SHA1 Message Date
Ed Page
acb0fb7809 fix: Generalize mut_arg, like mut_subcommand
This makes us accept `str` and not do any allocations at the cost of
panicing if unsupported which I think fits our overall story in trying
to catch development-time errors.
2022-09-16 15:31:49 -05:00
Ed Page
dbf2c86995 perf: Misc simplifications for code size
This dropped a fraction of a KiB but it will at least not cause people
to ask if it'd help to simplify in the future.
2022-09-16 15:31:49 -05:00
Ed Page
14c6ce0e83 fix(derive): Remove next_help_heading isolation
Originally, I saw the ideal as the parent command being isolated from
`#[clap(flatte)]` especially after all of the doc comment
leakage issues.  We scaled that back to just `next_help_heading` because
of the issues with settling on a policy and maintenance to cover
everything.  When doing `next_display_order`, we decided it would mess
things up too much to isolate it.

With #1807, we instead have been moving towards setting
`#[command(next_help_heading)]` anywhere, we just need to finish working
out how it should work.
2022-09-16 15:31:49 -05:00
Ed Page
417f1a9813 fix(derive): Read CARGO_PKG_NAME at runtime
This was broken in #4168
2022-09-16 14:31:58 -05:00
Ed Page
71cdd240e5
Merge pull request #4220 from epage/quote
fix(parser): Quote the suggested help
2022-09-15 16:36:14 -05:00
Ed Page
0184cf008a fix(parser): Quote the suggested help
We do it elsewhere but here it is only distinguished coloring.

Inspired by #4218
2022-09-15 16:24:59 -05:00
Ed Page
0479d8eb40
Merge pull request #4219 from epage/sub
fix(parser): Prefer invalid subcommands over invalid args
2022-09-15 10:42:35 -05:00
Ed Page
b7d13dfb88 fix(parser): Prefer invalid subcommands over invalid args
Just having `--help` or `--version` can make us get invalid args instead
of invalid subcommands.   It doesn't make sense to do this unless
positionals are used.  Even then it might not make sense but this is at
least a step in the right direction.

Unsure how I feel about this being backported to clap 3.  It most likely
would be fine?

This was noticed while looking into #4218
2022-09-15 10:30:03 -05:00
Ed Page
69c2d65ca9
docs(contrib): Fix version support table 2022-09-13 15:42:41 -05:00
Ed Page
7ee121a2e0
Merge pull request #4213 from epage/reset
feat: Allow resetting builder methods
2022-09-13 15:27:59 -05:00
Ed Page
23ce67e323 feat: Allow resetting builder methods
Fixes #4178
2022-09-13 15:16:57 -05:00
Ed Page
f68500d9fd fix: Replace Arg::env with Arg::env_os
With `Into<OsStr>`, the separate function isn't needed.
2022-09-13 14:55:12 -05:00
Ed Page
ee387c66f9
Merge pull request #4212 from epage/width
docs: Clarify role of max_term_width
2022-09-13 13:53:19 -05:00
Ed Page
da9691d369 docs: Clarify role of max_term_width 2022-09-13 11:40:06 -05:00
Ed Page
d2503a4a88
Merge pull request #4209 from epage/prep
feat(derive): Reserve behavior needed for implicit ArgGroups
2022-09-13 08:50:05 -05:00
Ed Page
d3bf5450ff feat(derive): Reserve the T group name
Since the `name` is changed to be the package name, we can't use it as
(1) its not as predictable and (2) it can lead to conflicts if a
`Parser` is flattened into a `Parser`
2022-09-13 07:44:36 -05:00
Ed Page
01c0975678 feat(derive): Reserve 'group_id' trait method 2022-09-13 07:06:12 -05:00
Ed Page
3bfa9d5ff0 feat(derive): Reserve 'group' attribute 2022-09-13 07:06:06 -05:00
Ed Page
79321f25e4
Merge pull request #4208 from epage/columns
fix(help): Respect LINES and COLUMNS
2022-09-12 21:18:00 -05:00
Ed Page
0eb95022a5 fix(help): Respect LINES and COLUMNS
Fixes #4186
2022-09-12 20:17:20 -05:00
Ed Page
0760498200 refactor(help): Allow looking up dimensions independently 2022-09-12 19:55:13 -05:00
Ed Page
1466cd5f55
Merge pull request #4207 from epage/arg
fix: Make `arg!(--flag <value>)` optional by default
2022-09-12 19:47:59 -05:00
Ed Page
c9eef44213 fix: Make arg!(--flag <value>) optional by default
This was ported over from the usage parser which modeled after docopt.
We just never got around to implementing the rest of the syntax.

However, when considering this as a standalone feature, an
`arg!(--flag <value>)`, outside of other context, should be optional.
This is how the help would display it.

Fixes #4206
2022-09-12 17:10:01 -05:00
Ed Page
75a73f3fe0 docs: Feature moved to v3 2022-09-12 16:25:18 -05:00
Ed Page
a86e55ad3e docs: Add more highlights 2022-09-09 19:06:33 -05:00
Ed Page
fadcaf9860 docs: Help people through Action changes 2022-09-08 16:02:12 -05:00
Ed Page
6f185a8704 docs: Clarify intent of upgrade link 2022-09-08 15:56:56 -05:00
Ed Page
bf98110adc
Merge pull request #4197 from epage/dynamic
fix: Tests/clippy/errors bash dynamic completion
2022-09-07 20:25:20 -05:00
Roland Fredenhagen
a2cf7f1dea fix: Tests/clippy/errors bash dynamic completion 2022-09-07 20:25:06 -05:00
Ed Page
4e703d1e2e
Merge pull request #4193 from epage/stable
revert(derive): Bald action/value_parser are deprecated, its good enough
2022-09-07 20:01:00 -05:00
Ed Page
430a384984
Merge pull request #4196 from epage/link
docs(parser): Clarify needs for negative numbers
2022-09-07 20:00:49 -05:00
Ed Page
81c3925bb8
Merge pull request #4194 from epage/assert
perf(assert): Don't make release pay the cost
2022-09-07 20:00:35 -05:00
Ed Page
fa7a1fca58 docs(parser): Clarify needs for negative numbers 2022-09-07 19:48:10 -05:00
Ed Page
afeed4043c perf(assert): Don't make release pay the cost 2022-09-07 19:43:26 -05:00
Ed Page
17f49df4e2 revert(derive): Bald action/value_parser are deprecated, its good enough
When I removed these in v5, we didn't have a deprecation approach for
the derive and I didn't want to forget.  Now we do have a deprecation
approach and that is the reminder, so we don't need to carry around v5
changes.
2022-09-07 19:34:50 -05:00
Ed Page
b502ac750b docs: Summarize reason for change 2022-09-07 19:30:57 -05:00
Ed Page
a9333b7074 docs: Specify that we will support prior major versions
This came up in a [reddit
discussion](https://www.reddit.com/r/rust/comments/vbep9q/clap_32_last_call_before_40/ic91vul/)
and seems like a way we can reduce concerns over clap churn without an
undue burden on maintainers.
2022-09-07 19:12:01 -05:00
Ed Page
985a1b9b4a docs(derive): Collect tips at end 2022-09-07 18:56:05 -05:00
Ed Page
c95c9f2fac
Merge pull request #4192 from epage/tab
fix(help): Make output more dense
2022-09-07 18:52:29 -05:00
Ed Page
c90a4eabae fix(help): Make output more dense
In looking at other help output, I noticed that they use two spaces, in
place of clap's 4, and it doesn't suffer from legibility.  If it
doesn't make the output worse, let's go ahead and make it as dense so we
fit more content on the screen.

This is a part of #4132
2022-09-07 17:13:55 -05:00
Ed Page
ed6475e9de fix(help): Clarify what is tab dependent and what isn't 2022-09-07 16:39:14 -05:00
Ed Page
56fe50eab8 fix(help): I think this fixes a bug?
The existing behavior is hard to explain, so this is the best I've
figured is going on.
2022-09-07 16:38:33 -05:00
Ed Page
876da97d1c fix(help): Make next-line help less sensitive to tab changes 2022-09-07 15:52:26 -05:00
Ed Page
d3fc37b678 fix(help): Long-only indentation is independent of TAB 2022-09-07 15:07:47 -05:00
Ed Page
65c289784b
Merge pull request #4190 from epage/nxt
fix(help):Be dense on short next line help
2022-09-07 14:28:06 -05:00
Ed Page
bbb6c38bad fix(help):Be dense on short next line help
If short help is too long for the terminal, clap will automatically
switch to next line help.  As part of next line help for longs, we add a
blank line between args.  This helps make the args clearer when dealing
with multiple paragraphs.  However, its not as much needed for short and
subcommands (always short), so now short matches subcommands.

This was inspired by #3300 and a part of #4132
2022-09-07 14:05:17 -05:00
Ed Page
69dd145767 docs: Fix code fence 2022-09-07 13:40:03 -05:00
Ed Page
b7b12ea558 docs: Add another highlighted difference 2022-09-07 12:45:25 -05:00
Ed Page
55e2297174 docs: Write v4 migration 2022-09-07 12:43:57 -05:00
Ed Page
4cb42c640d
Merge pull request #4189 from epage/last
docs: Show how last can be used
2022-09-07 11:44:28 -05:00