Ed Page
41535d5c46
feat: Extend number_of_values
to support min/max per occurrence
2022-07-28 16:52:25 -05:00
Ed Page
b4dfdcea15
fix!: Change number_of_values to be per occurrence
2022-07-28 16:52:16 -05:00
Ed Page
630a4894b3
fix(error): Ensure empty possible values isn't shown
2022-07-28 16:48:47 -05:00
Ed Page
8e20782bfd
fix(parser): Rely on default_missing_value
for flag actions
...
In the short term, this just provides a back door to custom actions.
Longer term, we can explore a `SetConst` action that relies on this
behavior. Really, `SetTrue` and `SetFalse` are shortcuts for such an
action but shortcuts can be helpful for usability.
Apparently, this also reduced `.text` size by 1k
2022-07-28 15:43:08 -05:00
Ed Page
f76a867e3f
fix: Simplify flag parsing
...
Multiple values can only happen from env variables when configured by
the user, so let's not go out of our way to deal with it.
2022-07-28 15:31:40 -05:00
Ed Page
8aa960c984
style: Make clippy happy
2022-07-28 15:11:28 -05:00
Ed Page
c2f5d8d7b7
perf: Reduce amount of code for rendering args
...
Rendering of usage is not in a critical path, so should be more worried
about binary size than performance. That only leaves avoiding coloring
spaces. That shouldn't be a problem, so let's make the binary smaller.
2022-07-28 14:56:33 -05:00
Ed Page
a7a96e02fa
refactor(help): Simplify rendering of arg values
2022-07-28 14:46:19 -05:00
Ed Page
355a8ff90c
fix!: number_of_values
doesn't always imply multiple_values(true)
...
With `number_of_values` being per-occurrence now, its doesn't make sense
for `number_of_values(0)` to set `takes_value(true)` or for
`number_of_values(1)` to set `multiple_values(true)`.
In addition, an assert is made if the user works around this
2022-07-28 14:40:58 -05:00
Ed Page
2be2924f91
test(help): Veriy rendering of min_values
2022-07-28 13:33:42 -05:00
Ed Page
5eedb03e45
fix(help): Mark positionals as optional
2022-07-28 13:12:26 -05:00
Ed Page
43aa695ad7
refactor: Abstract access to min_vals
2022-07-28 13:12:18 -05:00
Ed Page
67adc4acf9
fix(parser)!: Apply default_missing_value per occurrence
...
This both simplifies the code and the model we present to the user,
making more sense.
There is room for further exploration of tying flag actions into this.
2022-07-27 20:23:58 -05:00
Ed Page
5f20fe1930
docs: Shift focus from takes_value to actions
2022-07-26 14:50:51 -05:00
Ed Page
8e9c4c6c64
fix: Be explicit on help/version action
2022-07-26 09:34:23 -05:00
Ed Page
8ea1e2d4d3
fix!: Use value parsers for external subcommands
...
This changes the default type as well to encourage preserving the full
information for shelling out. If people need UTF-8, then they can
change the value parser.
Fixes #3733
2022-07-25 14:31:56 -05:00
Ed Page
475a0fc0a2
fix!: Remove PartialEq from Command
...
This gives us more implementation flexibility
2022-07-25 13:52:13 -05:00
Ed Page
13e672fb90
fix(assert)!: Prevent repeated subcommand names
...
Fixes #3888
2022-07-25 13:46:18 -05:00
Ed Page
6f03b4f948
fix!: Remove multiple occurrences in favor of Append/Count
...
For num_vals and friends, this only implements hacks until #2688
Fixes #3021
2022-07-25 13:23:43 -05:00
Ed Page
8c7fe8bb2f
Merge pull request #3986 from epage/override
...
fix(assert)!: Disallow self-overrides
2022-07-25 12:58:59 -05:00
Ed Page
b47a8453d7
Merge pull request #3933 from emersonford/vec-value-enum-default-value-t
...
feat(clap_derive): Add `default_values_t` and `default_values_os_t` for Vec field types
2022-07-25 12:54:43 -05:00
Ed Page
ec38212dcb
fix(assert)!: Disallow self-overrides
...
This will make it easier to drop support for multiple occurrences
2022-07-25 12:46:16 -05:00
Ed Page
5a8e2046af
fix(assert)!: Ensure overrides_with IDs are valid
2022-07-25 12:26:32 -05:00
Emerson Ford
04e0ed7474
feat(clap_derive): Add default_values_t
and default_values_os_t
2022-07-25 10:14:04 -07:00
Tshepang Mbambo
2facce8301
docs: Remove extraneous words
2022-07-25 15:47:49 +02:00
Tshepang Mbambo
ec9dcaaf16
docs: Fix a typo
2022-07-24 16:00:59 +02:00
Ed Page
a3356aae43
fix!: Remove more deprecated APIs
2022-07-23 21:23:06 -05:00
Ed Page
0eaec6085a
Merge pull request #3978 from epage/perf
...
perf: Remove some monomorphization bloat
2022-07-23 21:17:07 -05:00
Lioness100
304297e5c8
docs: remove extra bracket typo
2022-07-23 08:23:11 -07:00
Ed Page
8e38caadcc
perf: Remove some monomorphization bloat
...
When checking into binary size, I noticed that the `git` example is a
lot larger than v3. `git bisect` narrowed it down to
11076a5c70
which doesn't make sense. I
did noticed we could remove some bloat from monomorphization.
Overall for `cargo-example, we've dropped about 47 KiB.
2022-07-22 21:02:45 -05:00
Ed Page
08e8642a8c
Merge pull request #3976 from epage/attrib
...
fix(derive)!: Remove value_parser/action defaulted attributes
2022-07-22 20:25:09 -05:00
Ed Page
6ecb7310a8
fix(derive)!: Remove value_parser/action defaulted attributes
2022-07-22 20:07:47 -05:00
Ed Page
50259e51d5
fix!: Remove deprecated ArgActions
2022-07-22 20:07:24 -05:00
Ed Page
122b562e6b
fix!: Change default actions to Set/SetTrue
...
This is in prep for removing StoreValue/IncOccurrences
2022-07-22 20:00:47 -05:00
Ed Page
4b499ac024
docs(env): Fix bool example
2022-07-22 19:51:23 -05:00
Ed Page
0039ef91fa
fix: Have arg! collection across flags for positionals
2022-07-22 19:51:23 -05:00
Ed Page
3356e24360
refactor: Move action defaulting to where it belongs
2022-07-22 19:46:07 -05:00
Ed Page
3ca27f0879
refactor: Remove dead code for NoAutoHelp/NoAutoVersion
2022-07-22 19:42:49 -05:00
Ed Page
24735e3a1d
fix!: Pull AppSettings out of API
...
Part of #3021
2022-07-22 16:05:54 -05:00
Ed Page
11076a5c70
fix(help)!: Make DeriveDisplayOrder
the default, removing it
...
Force sorting with `next_display_order(None)`
Fixes #2808
2022-07-22 15:52:03 -05:00
Ed Page
389ff4ff21
fix(help): Subcommand display order respects Command::next_display_order
...
Previous behavior:
- They'd be sorted by default
- They'd derive display order if `DeriveDisplayOrder` was set
- This could be set recursively
- The initial display order value for subcommands was 0
New behavior:
- Sorted order is derived by default
- Sorting is turned on by `cmd.next_display_order(None)`
- This is not recursive, it must be set on each level
- The display order incrementing is mixed with arguments
- This does make it slightly more difficult to predict
2022-07-22 15:03:16 -05:00
Ed Page
e09a3321af
fix!: Ignore required when subcommands conflict with required
...
Fixes #3940
2022-07-22 14:10:27 -05:00
Ed Page
36dcb05d96
fix!: Change arg!
to use ArgAction
...
Fixes #3795
2022-07-22 13:24:40 -05:00
Ed Page
b77ed545ac
fix(env)!: Parse help/version like normal
...
Fixes #3776
2022-07-22 13:12:12 -05:00
Ed Page
8b064cfee9
fix(derive): Move off of SubcommandRequiredElseHelp
...
This also let us remove the deprecated attribute
Fixes #3280
2022-07-22 12:33:31 -05:00
Ed Page
50019cacdc
Merge pull request #3967 from epage/parse
...
fix(derive)!: Remove deprecated parse attribute
2022-07-22 12:27:43 -05:00
Ed Page
7068586246
fix(derive)!: Remove deprecated parse
attribute
2022-07-22 12:14:29 -05:00
Ed Page
0d459128d7
fix(error)!: Merge UnrecognizedSubcommand into InvalidSubcommand
...
Fixes #3676
2022-07-22 12:12:35 -05:00
Ed Page
a842bd64a0
fix!: Use display_name rather than bin_name in version output
2022-07-22 11:40:30 -05:00
Ed Page
01a3ea425f
fix!: Remove unstable-v4
feature gate
2022-07-22 11:34:06 -05:00