Ed Page
0c668c3915
refactor(help): Pull out bin name logic
2023-11-09 12:03:35 -06:00
Ed Page
7472aba6ce
refactor(help): Clarify usage condition
2023-11-09 12:00:52 -06:00
Ed Page
676e934a61
refactor(help): More directly write args
2023-11-09 11:57:15 -06:00
Ed Page
acdd2c33f0
refactor(help): Make usage argument order consistent
2023-11-09 11:50:46 -06:00
Ed Page
da98eb1a05
refactor(help): Pull out top-level usage logic
2023-11-08 11:49:07 -06:00
Ed Page
f50800f763
refactor(help): Only trim the end on usage
2023-11-08 11:42:54 -06:00
Ed Page
f04f04111b
refactor(help): Switch usage creation to writing
2023-11-08 11:25:43 -06:00
Ed Page
6f7174cc7c
refactor(help): Pull out usage separator
2023-11-08 11:10:55 -06:00
Ed Page
28425e484f
style(docs): Resolve warnings
2023-11-07 13:44:41 -06:00
Ed Page
9bfa5a338c
chore: Release
2023-10-24 13:25:07 -05:00
Ed Page
38b5a2f956
chore: Release
2023-10-24 11:45:21 -05:00
Alex Crichton
9a9aabc178
refactor: Reduce code size of testing tokens if they're a number
...
This commit is a tiny win in compiled code size of a final binary
including `clap` which shaves off 19k of compiled code locally.
Previously tokens were checked if they were a number by using
`.parse::<f64>().is_ok()`, but parsing floats is relatively heavyweight
in terms of code size. This replaces the check with a more naive "does
this string have lots of ascii digits" check where the compiled size of
this check should be much smaller.
2023-10-24 09:17:45 -07:00
Kevin Reid
71c1e59334
docs: Fix doc link to Arg::trailing_var_arg
2023-10-14 18:11:33 -07:00
Ed Page
dfebb54423
style: Make clippy happy
2023-10-12 08:32:59 -05:00
Josh Triplett
416b1a8da7
fix: Remove unused dev-dependencies
...
These dependencies are used elsewhere in clap, but not in these crates.
`cargo test` and `cargo check --examples` both still pass with these
dependencies removed.
2023-10-10 20:11:33 +08:00
Ed Page
29f22c193c
Merge pull request #5160 from epage/docs
...
docs: Provide custom version/help flag examples
2023-10-04 17:01:16 -05:00
Ed Page
da7ebca04e
docs: Provide custom help flag example
2023-10-04 16:25:31 -05:00
Ed Page
e74864f88a
docs: Provide custom version flag example
2023-10-04 16:22:46 -05:00
renovate[bot]
4054a0c1a5
chore(deps): update compatible (dev) ( #5151 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-10-01 01:52:25 +00:00
Ed Page
39f5e807af
chore: Release
2023-09-28 14:36:28 -05:00
Ed Page
485b957c4b
chore: Upgrade anstream
2023-09-28 14:13:54 -05:00
Ed Page
c298f6a52c
chore: Release
2023-09-25 15:59:01 -05:00
Ed Page
3ac44040ef
Merge pull request #5025 from SUPERCILEX/resolve-alias-conflicts
...
fix: Resolve conflicting name inference if from aliases
2023-09-25 15:56:28 -05:00
Alex Saveau
a76789eb8b
fix: Make long subcommand flag inference consistent
...
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-25 13:28:27 -07:00
Alex Saveau
c2b8ec3bd3
fix: Resolve conflicting name inference if from aliases
...
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-09-25 13:18:54 -07:00
Ed Page
221177b9cb
fix(assert): Call out the action in positional assert
...
Brought up in #5135
2023-09-25 10:18:37 -05:00
Ed Page
c344edf8b9
docs: Clarify most asserts are for debug builds
2023-09-19 12:38:21 -05:00
Ed Page
e6e539660f
chore: Release
2023-09-18 09:28:47 -06:00
Colin Walters
84f99ff979
chore(builder): Bump terminal_size to 0.3
...
For some reason, terminal_size bumped semver recently; they
also bumped the rustix version to 0.38.
I'd like to reduce the number of copies of OS integration
crates (rustix and nix) in my dependency chain. Let's bump
to the new version so I can aim to drop rustix 0.37.
2023-09-18 10:31:19 -04:00
renovate[bot]
dc63cba772
chore(deps): update compatible (dev) ( #5108 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-09-01 01:47:45 +00:00
Ed Page
3cd571e654
chore: Release
2023-08-31 13:19:11 -05:00
Ed Page
7a4f7d3f2c
Merge pull request #5106 from epage/once
...
perf: Drop a dep for faster builds
2023-08-31 13:18:15 -05:00
Ed Page
087224a486
perf: Drop a dep for faster builds
...
`OnceLock` became available as of 1.70 which is older than our new MSRV.
We can easily get away without `Lazy` variants.
2023-08-31 12:54:45 -05:00
Joe Chen
4012b195fd
fix(builder): Update documentation comments
2023-08-31 13:22:35 +08:00
Ed Page
7126f78421
chore: Release
2023-08-28 11:45:19 -05:00
Ed Page
eb53db89f8
feat(help): Stabilize styling support
...
Fixes #3234
2023-08-28 09:49:48 -05:00
Ed Page
2e49645418
chore: Release
2023-08-24 11:08:02 -05:00
Ed Page
0b196a165c
perf(builder): Speed up builds by dropping is-terminal
2023-08-24 10:19:28 -05:00
Ed Page
88cf306216
chore: Release
2023-08-23 09:21:22 -05:00
Ed Page
bf3f25ebb2
fix(help): Ensure padding isn't stripped
...
Fixes #5083
2023-08-22 16:02:33 -05:00
Ed Page
b9df80c2ce
chore: Release
2023-08-18 16:07:31 -05:00
Ed Page
56135f3ff3
fix(builder): UnknownValueParser shouldn't error on flag absense
...
Fixes #5079
2023-08-18 14:29:37 -05:00
Ed Page
6720240577
feat(parser): Report source to value parsers
2023-08-18 14:28:15 -05:00
Ed Page
df337de701
chore: Release
2023-08-17 08:59:45 -05:00
Ed Page
9f65eb0c9a
refactor(error): Give caller control over suggestion
2023-08-16 14:54:45 -05:00
Ed Page
8413c155d2
feat(builder): Allow injecting known unknowns
...
Fixes #4706
2023-08-16 14:50:08 -05:00
Ed Page
ee1388c0a3
chore: Release
2023-08-07 20:36:44 -05:00
Ed Page
3156e1a35c
Merge pull request #5066 from 9999years/export-trymapvalueparser
...
feat: Allow referencing `TypedValueParser` in`ValueParserFactory` associated type
2023-08-07 20:35:49 -05:00
Ed Page
b96cbafcbe
chore: Release
2023-08-07 20:33:13 -05:00
Rebecca Turner
c86172e891
feat: Export builder::TryMapValueParser
...
Partial fix for #5065 , allows using TypedValueParser::try_map to
implement a ValueParserFactory.
2023-08-03 15:53:38 -07:00
renovate[bot]
6cd2706bf4
chore(deps): update compatible (dev) ( #5059 )
...
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2023-08-01 01:20:36 +00:00
Josh Triplett
9c090262cd
feat: Command::mut_args
to modify all arguments
...
Convenient when you want to modify most or all arguments, without having
to call `mut_arg` for each one and name them all.
2023-07-28 21:16:29 -07:00
Ed Page
ae5549d61f
chore: Release
2023-07-21 16:56:00 -05:00
Ed Page
8bee728034
fix(parser): Value terminator has higher precedence than later multiple values
...
This is one of several bugs found when looking at #4960 .
2023-07-21 16:41:08 -05:00
Ed Page
9856d67541
chore: Release
2023-07-21 14:44:34 -05:00
Ed Page
6590a855ee
fix(parser): Don't suggest -- as often
...
See #2766
2023-07-21 14:27:15 -05:00
Ed Page
d824b1f0fd
chore: Release
2023-07-19 11:05:53 -05:00
Ed Page
8b536e2719
fix(help): Wrap long possible values correctly
...
We weren't taking the name into account when determining the wrap width.
Fixes #5022
2023-07-19 10:42:09 -05:00
Ed Page
95d411d151
chore: Release
2023-07-18 15:01:21 -05:00
Ed Page
4caa536ca4
fix(assert): Allow stateful value parsers
...
We'll need to re-evaluate how to solve #3202 .
Fixes #4643
2023-07-18 14:11:56 -05:00
Ed Page
51abbe7ebf
chore: Release
2023-07-17 20:12:05 -05:00
Ed Page
82f17a40c0
docs(builder): Provide styling examples
2023-07-17 17:10:33 -05:00
Ed Page
e31768bb55
fix(builder): Re-export anstyle for easy access
2023-07-17 17:10:13 -05:00
Ed Page
98f62d1939
chore: Release
2023-07-17 10:55:26 -05:00
Ed Page
36afe99bfa
fix(help): Skip [OPTIONS]
if help/version action
...
Our code for detecting when to skip this in the usage was never updated
for actions.
2023-07-17 10:40:42 -05:00
Ed Page
22b545b98b
feat(help): Explicit control over short/long help
...
Fixes #4687
2023-07-17 10:37:26 -05:00
Ed Page
c2191674b0
chore: Release
2023-07-17 10:26:48 -05:00
Ed Page
bc000aa4b0
fix(help): Defaulting max_term_width instead of max_term_width
...
Fixes #4295
2023-07-17 09:40:49 -05:00
Ed Page
d741e9519c
docs(builder): Correct max_term_width docs
2023-07-17 09:25:21 -05:00
Ed Page
f8d86dc165
refactor(help): Break term width calculation out
2023-07-17 09:17:52 -05:00
Ed Page
fcda411e5e
chore: Release
2023-07-14 12:01:56 -05:00
Ed Page
6541df2c4b
docs: Note user-values subject to value_delimiter
...
Inspired by #4999
2023-07-07 09:07:55 -05:00
Ed Page
cafdf58e02
chore: Release
2023-07-05 10:33:25 -05:00
Ed Page
99bcdfc6c7
style(builder): Be consistent in order
2023-07-05 10:10:34 -05:00
Ed Page
a50e32c135
feat(derive): Accept Boxed Str/OsStr/Path
2023-07-05 10:03:52 -05:00
Ed Page
916c8d93e1
feat(derive): Accept num::Wrapping wrapped types
2023-07-05 09:55:31 -05:00
Ed Page
f043f57559
feat(derive): Accept Box/Arc wrapped types
2023-07-05 09:53:41 -05:00
Ed Page
7353b2be34
chore: Release
2023-06-29 20:45:17 -05:00
Ed Page
27431a43a1
refactor(builder): Remove bitflags dependency
...
This saved 1.3 KiB
When color support is enabled, this likely won't save on build times
*until* `is-terminal` is removed. At that point, `bitflags` will no
longer be in our dependency tree.
I did not (yet) reproduce the `Debug` impl.
2023-06-29 20:24:34 -05:00
Ed Page
6bfd7852ac
chore: Update bitflags
...
Fixes #4861
2023-06-29 19:46:59 -05:00
Ed Page
18f0ad4676
chore: Release
2023-06-28 08:39:55 -05:00
Sebastian Toh
8103e9760a
fix(ignore_errors): Allow help and version command
2023-06-28 08:58:40 +08:00
Ed Page
1f71fd9e99
chore: Release
2023-06-23 16:36:03 -05:00
Ed Page
8596fe6523
Merge pull request #4971 from SUPERCILEX/long-arg-inference
...
fix: Broken long arg inference on conflicts
2023-06-23 16:34:19 -05:00
Ed Page
cf7f3a7ba0
chore: Release
2023-06-20 11:15:10 -05:00
Pavan Kumar Sunkara
cfd1d22e26
Improve colorchoice enum
2023-06-20 08:55:04 +01:00
Ed Page
3ad2bf6061
docs(builder): Describe current sort semantics
...
I must have been moving too fast with 6e1e754
as it changed the wrong
part of the text when really the whole thing needed an overhaul.
So this correctly fixed #4728
2023-06-19 09:33:27 -05:00
Alex Saveau
f9994bff47
fix: Broken long arg inference on conflicts
...
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-06-17 13:30:05 -07:00
Ed Page
dcccf61099
chore: Release
2023-06-14 08:55:02 -05:00
Sebastian Pipping
36329896e7
feat: Extract/add public method Error.exit_code
...
Simplifies method Error.exit as a side effect.
2023-06-14 01:39:59 +02:00
Ed Page
a87fba2bb6
chore: Release
2023-06-09 09:34:30 -05:00
Ed Page
d10938dd33
feat: Allow deferred initialization of subcommands
...
This is mostly targeted at reducing startup time for no-op commands
within *very* large applications, like deno (see #4774 ).
This comes at the cost of 1.1 KiB of binary size
2023-06-09 08:29:38 -05:00
Ed Page
5661b6b508
style: Remove unused mut
2023-06-05 12:49:26 -05:00
Ed Page
50f0e6bffb
chore: Release
2023-06-01 21:10:46 -05:00
renovate[bot]
534be345d8
chore(deps): update compatible (dev)
2023-06-01 00:38:25 +00:00
Ed Page
9c3dc187cb
chore: Release
2023-05-19 11:55:42 -05:00
Ed Page
5047bb40bd
chore: Release
2023-05-19 11:48:29 -05:00
Ed Page
e1db168d69
fix(parser): Ensure terminated positionals are assigned correctly
2023-05-19 10:41:44 -05:00
Ed Page
1ee2e95e96
fix(builder): Allow value terminated multiple positional values
2023-05-19 10:39:05 -05:00
Ed Page
c3fe7ff0a9
fix(help): Don't use next-line-help on long-help for subcommands
...
Subcommands don't switch their behavior on `--help`, so let's not switch
to next-line-help based on `--help`.
Fixes #4897
2023-05-12 10:41:05 +02:00
Ed Page
21d911db10
style: Make clippy happy
2023-05-19 09:10:20 -05:00
Ed Page
8edf8c7676
Merge pull request #4922 from epage/docs
...
docs(builder): Remove stale docs references (set is default)
2023-05-19 09:02:18 -05:00
Ed Page
ac5d893091
docs(builder): Remove stale docs references (set is default)
2023-05-18 13:11:14 -05:00
Wim Looman
c41f4beaaa
fix(docs): Add note about Command::disable_help_subcommand applying to children
2023-05-18 14:11:22 +02:00
Ed Page
1d42caa0b6
Merge pull request #4912 from epage/assert
...
fix(assert): Clarify last assertion
2023-05-17 17:10:08 -05:00
Ed Page
67cc5ea3a2
fix(assert): Clarify last assertion
...
An incremental improvement for #4911 .
2023-05-17 16:33:36 -05:00
Daniel Hofstetter
3458adc6ae
fix: Typo in value_parser.rs
2023-05-15 15:35:25 +02:00
Yuri Astrakhan
d0302c5556
chore: Inline simple non-mixed format args
2023-05-04 15:58:04 -04:00
Ed Page
ba9cad6ca2
Merge pull request #4885 from epage/possible
...
refactor(help): Clean up long possible value handling
2023-05-03 21:17:45 -05:00
Ed Page
5fb1b25799
Merge pull request #4883 from nyurik/happy-clippy
...
chore: Make Clippy happy
2023-05-03 21:13:47 -05:00
Yuri Astrakhan
ebbdce4820
chore: Make Clippy happy
2023-05-03 21:56:07 -04:00
Yuri Astrakhan
797c23c415
chore: Inline format args using clippy fix
...
This command cleaned up all the format args,
making code significantly shorter and more readable.
```
cargo clippy --workspace --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2023-05-03 21:49:11 -04:00
Ed Page
1351c56289
fix(help): Consistently calculate PV name length
2023-05-03 20:15:31 -05:00
Ed Page
3963d73e18
perf(help): Remove next-help possible values
...
Next-line help for possible values does not feel like its pulling its
weight. If anything we should do next-line help for the entire
argument.
This dropped about 0.5 KiB but more importantly is prep for other
changes.
2023-05-03 20:09:36 -05:00
Ed Page
ec52b74d68
refactor(help): Better call out long-pv policy
2023-05-03 19:48:48 -05:00
Ed Page
9227ab1c7c
refactor(help): Be consistent in join style
2023-05-03 19:25:44 -05:00
Yuri Astrakhan
d810235d07
chore: Minor code dedup for writing possible vals
...
* writing possible values and subcommands used nearly identical code
* writing elements used duplicate code once for items and once for last item
2023-05-03 18:40:44 -04:00
Ed Page
baaf5c64c1
chore: Release
2023-05-02 14:07:29 -05:00
Ed Page
937f1ed9c9
fix(parser): Update iterator sizes as we go
...
Maybe it was just me, but I didn't realize that the length had to be
updated as we went but it can cause panics with a bad message.
Fixes #4870
2023-05-02 13:53:42 -05:00
Ed Page
a7214540f6
chore: Release
2023-05-02 13:24:34 -05:00
Dillon Shaffer
37507741c4
impl Eq<std::any::TypeId> for clap_builder::util::AnyValueId
2023-05-01 08:40:00 -06:00
Ed Page
fa57ed3123
chore: Release
2023-04-27 04:29:47 -05:00
Ed Page
9eaf8996a4
Merge pull request #4867 from epage/panic
...
fix(builder): Assert earlier on bad requires/conflicts
2023-04-27 18:57:19 -05:00
Ed Page
185729a7dc
fix(builder): Assert earlier on bad requires/conflicts
...
Fixes #4865
2023-04-27 04:16:14 -05:00
Ed Page
e02644b9c2
fix(usage): Provide more context in panic
2023-04-27 04:12:22 -05:00
mattmadeofpasta
296fec9186
test(help): Remove redundant test
2023-04-27 09:04:35 +00:00
Clement Tsang
89bf732353
docs: Update mut_arg docs on help + version flags
2023-04-20 22:18:27 -04:00
Ed Page
950a495753
fix(help): Preserve block indent when wrapping
2023-04-19 11:55:53 -05:00
Ed Page
4f0666d437
refactor(help): Clarify word splitter
2023-04-19 11:37:03 -05:00
Ed Page
60c8c3fc31
chore: Release
2023-04-19 11:11:47 -05:00
Ed Page
1ca073f212
docs(help): Fill in styles docs
2023-04-19 11:00:00 -05:00
Ed Page
6d5aaae5a9
feat(help): Allow access to current Styles
2023-04-19 10:57:00 -05:00
Ed Page
b99c50f7e9
chore: Release
2023-04-18 15:52:35 -05:00
Ed Page
cbea23e3fc
style: Make clippy happy
2023-04-18 15:36:02 -05:00
Ed Page
5ca3b2fc5f
refactor(help): Shrink binary size
2023-04-18 15:28:20 -05:00
Ed Page
ec7040e8ba
style: Make clippy happy
2023-04-18 15:22:42 -05:00
Ed Page
57974bed7b
refactor(help): Future proof styling
...
We can add a new style and default it to what it was split out of
without a breaking change.
2023-04-18 15:22:42 -05:00
Ed Page
e10e2ad249
refactor(help): Split out separate usage style
...
Because this doesn't have a full section after it, people might want to
style it differently than other headers.
2023-04-18 15:22:42 -05:00
Ed Page
8fd0a93bdc
refactor(help): Clarify style meaning
2023-04-18 15:22:42 -05:00
Ed Page
7cf08e63cd
refactor(help): Remove unused hint
2023-04-18 15:22:42 -05:00
Ed Page
015f88b21a
feat(help): Allow customizing terminal styling
...
For now, this is behind the `unstable-styles` feature as we verify this
is what we want for #3224
2023-04-18 15:22:42 -05:00
Ed Page
3cb90b0b22
refactor(help): Use a stylesheet
2023-04-18 15:22:42 -05:00
Ed Page
72515d14b1
refactor(help): Style in the caller
...
Random fixes along the way
- In one case the space after `tip:` was "colored" (won't matter until
themeing is available)
- One error case didn't color invalid values
- Changed the args associated with invalid values to be `literal` rather
than `warning`
- Changed the required value count to be `good`
- Changed the arg for invalid value counts to be `literal` (the actual
count is `warning`)
2023-04-18 15:22:42 -05:00
Ed Page
9416f3a347
refactor(help): Use anstyle in the caller
2023-04-18 15:22:42 -05:00
Ed Page
ab61cd6aaf
refactor(help): Push color knowledge out a layer
2023-04-18 15:22:42 -05:00
Ed Page
c8f5afe9b5
refactor: Make anstyle always available
2023-04-18 15:22:42 -05:00
Ed Page
690ae13f57
refactor: Track term widths as plugins
2023-04-13 02:23:18 -05:00
Ed Page
1924f45289
refactor: Design plugin system
2023-04-13 01:18:44 -05:00
Ed Page
fe70ddcb20
refactor(builder): Move Any out of parser
2023-04-13 00:28:00 -05:00
Ed Page
6f409544ec
chore: Release
2023-04-12 21:41:50 -05:00