Commit graph

6756 commits

Author SHA1 Message Date
Alex
e03201efbe
fix: Permissions syntax 2022-09-18 18:55:47 +01:00
Ed Page
574641ac63
Merge pull request #4225 from sashashura/patch-3
Update audit.yml
2022-09-17 14:36:42 -05:00
Alex
efc49747e7 chore: Update audit.yml 2022-09-17 15:22:06 +03:00
Ed Page
6dc8c9943c
Merge pull request #4223 from epage/string
perf: Switch to &'static str by default
2022-09-16 17:06:04 -05:00
Ed Page
1365b08849
Merge pull request #4222 from epage/size
fix: Misc fixes found when optimizing code size
2022-09-16 16:48:23 -05:00
Ed Page
c165b601ac perf: Switch to &'static str by default
Originally, clap carried a lifetime parameter.  When moving away from
that, we took the approach that dynamically generated strings are always
supported and `&'static str` was just an optimization.

The problem is the code size increase from this is dramatic.  So we're
taking the opposite approach and making dynamic formatting opt-in under
the `string` feature flag.  When deciding on an implementation, I
favored the faster one rather than the one with smaller code size since
small code size can be gotten through other means.

Before: 567.2 KiB, 15.975 µs
After: 541.1 KiB, 9.7855 µs
With `string`: 576.6 KiB, 13.016 µs
2022-09-16 16:44:39 -05:00
Ed Page
fe43f0c945 Revert "fix: Remove once_cell dependency from derive"
This reverts commit 429143af42.
2022-09-16 16:19:03 -05:00
Ed Page
bbbaca2ffe perf: Hint to the compiler when once_cell isn't needed 2022-09-16 16:14:32 -05:00
Ed Page
10854cd262 Revert "refactor: Remove once_cell dependency"
This reverts commit c9d883a8c6.
2022-09-16 16:14:32 -05:00
Ed Page
7ccaebb65d refactor(parser): Switch from Box<str> to String
This is a more familiar type for people and it didn't cost us anything
(in fact it undid the code size change in the last commit).
2022-09-16 16:14:32 -05:00
Ed Page
1e13109a26 refactor(parser): Track subcommands with Box<str>
The overall hope is to allow a `&'static str`-only version of clap, so
we need to move off of `Str` where dynamic strings are required.  We
need it here for subcommands due to external subcommands.

This had minimal impact on code size (567.2 to 567.5 KiB)
2022-09-16 16:14:32 -05:00
Ed Page
86b2fe5a2d refactor(parser): Reduce work when validating args 2022-09-16 16:14:16 -05:00
Ed Page
af9e1b9763 refactor(parser): Don't throwaway work 2022-09-16 16:14:16 -05:00
Ed Page
4869c43612 refactor: Simplify help subtree creation 2022-09-16 16:14:16 -05:00
Ed Page
3cadb8f255 docs(tutorial): Provide better default_value_t example 2022-09-16 16:14:16 -05:00
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