Commit graph

2899 commits

Author SHA1 Message Date
Ed Page
276c75cc08 fix: Don't pollute root with str types 2022-08-23 13:12:06 -05:00
Peter Grayson
bcd1062fdf
docs: How to override multi-line usage
Extend Command::override_usage() doc string to describe how to format
multiple usage lines to be compatible with clap's default help formatter.

Relates-to: #3413
2022-08-23 11:21:07 -04:00
Ed Page
907941a565 style: Make clippy happy 2022-08-22 16:07:56 -05:00
Ed Page
c9d883a8c6 refactor: Remove once_cell dependency 2022-08-22 16:07:14 -05:00
Ed Page
fc499ac0ec perf: Let users choose Str implementation
The binary size and performance difference is enough to make it
configurable.

Code size:
- default: 565.7 KiB
- perf: 578.5 KiB

Build time:
- default: 9.1706 us
- perf: 7.0479 us

Parse time:
- default: 12.673 us
- perf: 8.1708 us

Parse with subcommand time:
- default: 12.112 us
- perf: 7.9874 us
2022-08-22 15:47:21 -05:00
Ed Page
71752f56ea perf: Switch Str to use Box<Str>
Impact:
- Binary size: 556.6 KiB to 578.4 KiB 565.3 KiB
- build time: 9.6393 us
- parse time: 12.616 us
- parse sc time: 12.745 us
2022-08-22 14:56:16 -05:00
Ed Page
931d0e1bff perf: Switch Str to use String
Impact
- Binary size: 556.6 KiB to 578.4 KiB to 574.6 KiB
- build time: 9.4581 us
- parse time: 13.055 us
- parse sc time: 13.384 us
2022-08-22 14:56:16 -05:00
Ed Page
9b9e57628d refactor: Make Id consts more universal 2022-08-22 14:56:16 -05:00
Ed Page
049d6794b5 refactor: Isolate str inner 2022-08-22 14:56:16 -05:00
Ed Page
1bbf07e574 fix: Prefer more usable &str for reflection
The downside is we can't skip allocations with
- `ValueEnum` default values
- Vaid subcommands

Otherwise, this is a big ergonomic win.
2022-08-22 14:56:16 -05:00
Ed Page
85f541d789 fix: Switch to owned types
Impact:
- Binary size: 556.6 KiB to 578.4 KiB
- build time: 6.4950 us (7% slower)
- parse time: 7.7256 us
- parse sc time: 8.1580 us (5% faster)

Fixes #1041
Fixes #2150
2022-08-22 14:55:55 -05:00
Ed Page
6de312f50a fix: Ensure partial eq is symetric 2022-08-19 16:44:48 -05:00
Ed Page
8cc164dafb fix!: Remove lifetime from PossibleValue
Another step towards #1041

This isn't the long term type for `PossibleValue::help`, I just wanted
to get the lifetime out of the way first before figuring out how help
will work.
2022-08-19 12:44:29 -05:00
Ed Page
429143af42 fix: Remove once_cell dependency from derive
With being able to accept owned types now, `clap_derive` no longer needs
`once_cell` to make dynamic data static.

This helps towards #1365, #2037
2022-08-16 15:03:35 -05:00
Ed Page
91e55c6b9c fix: Switch OsStr's in builder to owned/borrowed type
This is a part of #1041

Because `Option<Into<T>>` is ambiguous for `None`, we had to create
`Resettable` to workaround it.
2022-08-16 14:53:36 -05:00
Ed Page
9074b60194 feat(parser): Make customizeing flags easier
While `TypedValueParser` will generally make it easier to reuse value
parsers, this was particularly written for flags.  Besides having a
concrete API to document, an advantage over `fn(&str) -> Result<bool, E>`
value parsers is you get all of the benefits of the existing value
parsers for environment variable parsing.
2022-08-19 08:21:55 -05:00
Ed Page
19d436d330 fix(parser): Move TypedValueParsers constraint earlier in process 2022-08-18 22:08:54 -05:00
Ed Page
09354dec21 fix: Allow non-bool value_parsers for SetTrue
Not sure if we could have originally made this work but it definitely
does now that we use `default_missing_value` for this (#4000)
2022-08-18 21:35:29 -05:00
Ed Page
5950c4b95f
Merge pull request #4084 from epage/predicate
fix!: Require/default conditional APIs are more explicit
2022-08-16 12:26:43 -05:00
Ed Page
09288b4bb9 fix!: Require/default conditional APIs are more explicit
This helps with
- API cleanup by not having ambigious `None`, see #950
- Removes ambiguity with `None` when using owned/borrowed types for
  #1041
2022-08-16 11:52:10 -05:00
Ed Page
17a07abd9f refactor: Remove lifetime from ArgPredicate 2022-08-16 10:58:58 -05:00
Ed Page
30d4ef4b09 fix: Allow OsStr for some required_if_eq calls 2022-08-16 10:22:24 -05:00
LeSeulArtichaut
ea55679de8 docs: Fix typo in markdown formatting 2022-08-16 14:55:53 +02:00
Ed Page
3c2635adb2 refactor: Make ArgPredicate non-copyable
This is prep for holding an owned type
2022-08-15 16:25:29 -05:00
Ed Page
2061a96619 refactor: Pull out distinct String type 2022-08-15 13:59:00 -05:00
Ed Page
2de59195aa fix!: Prefer IntoIterator over &[]
The main breakinge change cases:
- `&[char]`: now requires removing `&`
- All other non-ID `&[_]`: hopefully #1041 will make these non-breaking

Fixes #2870
2022-08-15 13:26:17 -05:00
Ed Page
dcfbee9787
Merge pull request #4080 from epage/iter
feat(parser): Report what arg ids are present
2022-08-15 11:15:30 -05:00
Ed Page
9c9cc9fcff docs(cookbook): Add position-sensitive example 2022-08-15 10:59:05 -05:00
Ed Page
7486a0b4b9 feat(parser): Report what arg ids are present
For now, we are focusing only on iterating over the argument ids and not
the values.

This provides a building block for more obscure use cases like iterating
over argument values, in order.  We are not providing it out of the box
at the moment both to not overly incentize a less common case, because
it would abstract away a performance hit, and because we want to let
people experiment with this and if a common path emerges we can consider
it then if there is enough users.

Fixes #1206
2022-08-15 10:00:42 -05:00
Chris Pryer
ec55eb6a20
docs: Quality improvements to FAQ docs 2022-08-13 19:32:03 -04:00
Ed Page
69e1e431e9 fix: Publicly expose 'Values' iterator 2022-08-12 17:05:02 -05:00
Ed Page
41be1bed08 fix(parser)!: Store args in a group, rather than values
Now that `Id` is public, we can have `ArgMatches` report them.  If we
have to choose one behavior, this is more universal.  The user can still
look up the values, this works with groups whose args have different
types, and this allows people to make decisions off of it when otherwise
there isn't enogh information.

Fixes #2317
Fixes #3748
2022-08-12 16:40:07 -05:00
Ed Page
004de00771 feat: Publicly expose Id 2022-08-12 16:25:47 -05:00
Ed Page
43ca9a2547 perf: Track static strs for Id
Unfortunately, this added another 6.6 KB

Compared to `HEAD~` on `06_rustup`:
- build: 7.41us -> 6.28us
- parse: 9.36us -> 8.07us
- parse_sc: 9.29us -> 7.74us

For context, this run compares `HEAD` to `v3-master`
```
build_rustup            time:   [10.765 µs 10.869 µs 10.981 µs]
                        change: [+72.716% +74.316% +75.832%] (p = 0.00 < 0.05)
                        Performance has regressed.
parse_rustup            time:   [14.264 µs 14.329 µs 14.407 µs]
                        change: [+75.565% +76.899% +78.172%] (p = 0.00 < 0.05)
                        Performance has regressed.
parse_rustup_with_sc    time:   [14.947 µs 15.025 µs 15.107 µs]
                        change: [+92.606% +94.079% +95.573%] (p = 0.00 < 0.05)
                        Performance has regressed.
```
So anything we are doing at this point is a large improvement.
2022-08-12 16:07:41 -05:00
Ed Page
5b5f2c1f40 fix!: Track original Ids, rather than a hash
This is a step towards #1041
- `ArgGroup` no longer takes a lifetime
- One less field type needs a lifetime

For now, we are using a more brute force type (`String`) so we can
establish performance base lines.  I was torn on whether to use `&str`
everywhere or make an `IdRef`.  The latter would add a lot of noise that
I'm concerned about, so i left it simple for now.  `IdRef` would help to
communicate the types involved though.

Speaking of communicating types, I'm also torn on whether we should use
`Id` for all strings or if we should have `Id`, `Name`, etc types to
avoid people mixing and matching.

This added 18.7 KB.

Compared to `HEAD~` on `06_rustup`:
- build: 6.23us -> 7.41us
- parse: 8.17us -> 9.36us
- parse_sc: 7.65us -> 9.29us
2022-08-12 15:46:04 -05:00
Ed Page
f84e38a4de fix!: Switch from &[] to IntoIterator
This is a part of #2870 and is prep for #1041

Oddly enough, this dropped the binary size by 200 Bytes

Compared to `HEAD~` on `06_rustup`:
- build: 6.21us -> 6.23us
- parse: 7.55us -> 8.17us
- parse_sc: 7.95us -> 7.65us
2022-08-12 15:45:02 -05:00
Ed Page
96f91ca092 refactor(assert): Make it easier to change id type
Compared to `master` on `06_rustup`:
- build: 5.74us -> 6.21us
- parse: 7.57us -> 7.55us
- parse_sc: 7.60us -> 7.95us
2022-08-12 15:43:22 -05:00
Ed Page
426a7d20f3 fix(debug): Clean up debug message 2022-08-12 13:06:09 -05:00
Ed Page
f1b86a6ae4 refactor(parser): Don't hide allocation 2022-08-12 13:04:48 -05:00
Ed Page
1849d566d2 refactor(assert): Remove dead code 2022-08-12 12:54:30 -05:00
Ed Page
ca046aaa01 refactor: Abstract away name's access
This is prep for merging name/id
2022-08-12 12:50:04 -05:00
Ed Page
d7735d5cf2 refactor: Move commands off of Id
This is prep for changing out the types

This dropped the size by 0.4 KB
2022-08-12 10:35:49 -05:00
Ed Page
43e961d24f style: Address clippy 2022-08-11 16:07:58 -05:00
Ed Page
e7ced880e2 docs: Fix for 1.63 2022-08-11 14:31:31 -05:00
Ed Page
6e7fd6d4bc refactor: Move off of IndexMap/HashMap
This dropped 17KB

Again, performance shouldn't be too bad as the total number of argument
id's passed in by the user shouldn't be huge, with the upper end being
5-15 except for in extreme cases like rustc accepting arguments from
cargo via a file.
2022-08-11 14:06:41 -05:00
Ed Page
d441ebbf62 refactor: Move off of IndexSet/HashSet
This dropped `.text` by 14KB

Anything in debug asserts or help/usage output doesn't matter for
performance but I wouldn't be surprised if this was comparable since the
container sizes we are talking about are relatively small.
2022-08-11 14:03:28 -05:00
Ed Page
3390adf0d3 chore: Bump MSRV to 1.60.0
While at it, this cleans up all of the features.  For some reason, I
couldn't do `dep:clap_derive` though.
2022-08-10 21:32:06 -05:00
Ed Page
07b6e66eb7 fix: No implicit version/help actions
Documenting the existing behavior is challenging which suggests it can
cause user confusion.  So long as its not too hard to explicitly
specify actions, we should just do it.

Fixes #4057
2022-08-10 21:21:53 -05:00
Ed Page
f70ebe89a7 fix!: Require explicit help/version disabling
Before we introduced actions, it required specific setups to engage with
claps version and help printing.  With actions making that more
explicit, we don't get as much benefit from our multiple, obscure, ways
of users customizing help

Before
- Modify existing help or version with `mut_arg` which would
  automatically be pushed down the command tree like `global(true)`
- Create an new help or version and have it treated as if it was the
  built-in on (I think)
- Use the same flags as built-in and have the built-in flags
  automatically disabled
- Users could explicitly disable the built-in functionality and do what
  they want

Now
- `mut_arg` no longer works as we define help and version flags at the
  end
- If someone defines a flag that overlaps with the built-ins by id,
  long, or short, a debug assert will tell them to explicitly disable
  the built-in
- Any customization has to be done by a user providing their own.  To
  propagate through the command tree, they need to set `global(true)`.

Benefits
- Hopefully, this makes it less confusing on how to override help
  behavior.  Someone creates an arg and we then tell them how to disable
  the built-in
- This greatly simplifies the arg handling by pushing more
  responsibility onto the developer in what are hopefully just corner
  cases
- This removes about 1Kb from .text

Fixes #3405
Fixes #4033
2022-08-10 20:33:21 -05:00
Ed Page
64639aa81c style: Make clippy happy 2022-08-10 11:41:27 -05:00
Ed Page
ac9f4727e0 fix(debug): Make it easier to address help issues
Inspired by #4033
2022-08-10 09:15:15 -05:00
Ed Page
9006f9a716
Merge pull request #4050 from epage/docs
docs: Clarify confusing API points
2022-08-09 16:48:29 -05:00
Ed Page
22c82c7404 docs(tutorial): Further expand on actions 2022-08-09 16:33:02 -05:00
Daniel Parks
1a2ae76738
fix(derive): Add "id" attribute
Previously the Arg id was set with the "name" attribute. This allows use
of an "id" attribute to match the underlying struct.

A side effect of this is that the "id" attribute may also be used on
Commands. This isn't desired, but given the current architecture of the
attribute parser, it's hard to avoid.

Fixes: #3785
2022-08-09 12:15:02 -07:00
Ed Page
2d352cb16f docs: Clarify intention for new APIs 2022-08-09 10:23:23 -05:00
Ed Page
f3d4c2c971 docs(derive): Remove clap v3 caveats 2022-08-08 14:15:00 -05:00
Ed Page
95207a1e6f fix: Ensure arg! gets help/version correct
Because of our changes from v3, we can't rely on `_build` taking care of
this for us.
2022-08-05 14:12:48 -05:00
Ed Page
0105b65e4e fix: Limit defaulting multiple values to Append 2022-08-05 13:38:11 -05:00
Ed Page
c801e4e56e fix!: Make ArgAction::Set the default
This removes the need for `TakesValue` bookkeeping for when we knew we
took values but didn't know how many we should take.

Fixes #2687
2022-08-05 13:31:33 -05:00
Ed Page
8ed35b4d9f fix: Provide convenient access for common cases 2022-08-05 12:06:54 -05:00
Ed Page
c1468d78b1 refactor: Renamge ValuesRange to ValueRange
Naming is hard.  I found I was writing new code without the `s` so that
suggests the name was wrong.  But we renamed `number_of_values` to
`num_args`, so should this be `ArgRange`?
2022-08-05 12:00:33 -05:00
Ed Page
e3153e3039 refactor: We don't need MultipleValues for bookkeeping afterall
TakesValue helps because it provides a way for a lot of settings to say
a value is needed without specifying how many.  Multiple values didn't
have enough call sites to make this worthwhile.

This is a part of #2688
2022-08-04 16:11:03 -05:00
Ed Page
32f308d4ef fix!: Make is_multiple_values private
multiple_values is now just book keeping for the builder, instead people
should look to actions and `num_args`.

The meaning for it was a little weird anyways.
2022-08-04 15:21:10 -05:00
Ed Page
6e1ca59ec1 fix!: Make is_takes_value_set private
At this point, it is an implementation detail to help with book keeping
within the builder.
2022-08-04 14:44:14 -05:00
Ed Page
52ec1f92e9 fix: Clarify that get_num_args is safe to call
The only time it won't be initialized is before `_build`.  This is possible because
of #4027

I wish I could just put the `expect` inside the call but I'm worried
about allowing people to build stuff on top of clap.
2022-08-04 14:21:53 -05:00
Ed Page
c62d3f0cfd fix!: Replace takes_value with number_of_values 2022-08-04 09:39:25 -05:00
Ed Page
29753b6798 fix: Remove references to number_of_values 2022-08-04 09:35:59 -05:00
Ed Page
479ca76491 fix: Always ensure num_args is initialized
As we move people off takes_value/multiple_values, this will provide
something to check.

This was previously blocked on other issues related to flag handling
(#4023)
2022-08-04 09:11:29 -05:00
Ed Page
85ad452c9b fix!: Remove Arg::rwquire_value_delimiter
In clap v3, `require_value_delimiter` activated an alternative parse
mode where
- `multiple_values` meant "multiple values within a single arg"
- `number_of_values` having no parse impact, only validation impact
- `value_names` being delimited values

For unbounded `number_of_values`, this is exactly what `value_delimiter`
provides.  The only value is if someone wanted `value_name` to be
`<file1>,<file2>,...` which can be useful and we might look into adding
back in.

Alternatively, this could be used for cases like key-value pairs but
that has issues like not allowing the delimiter in the value which might
be ok in some cases but not others.  We already instead document that
people should instead use `ValueParser` for this case.

In removing this, we remove points of confusion at how the different
multiple values and delimited value calls interact with each other.  I
know I would set `require_value_delimiter(true).multiple_values(true)`
when it turns out all I needed was `value_delimiter(',')`.

This also reduces the API surface area which makes it easier to discover
what features we do provide.

While this isn't big, this is also yet another small step towards
reducing binary size and compile times.
2022-08-03 21:26:36 -05:00
Ed Page
6b3a5bde6d fix(parser)!: Split on value delimiter after validating num_args
This will allow `num_args(0..=1).value_delimiter(',')` to work properly.

This hacks in support for `require_value_delimiter` until we can remove
it.

This no longer recognzes value terminators in delimited lists.

It looks like there is a bug with recognizing value terminators in
positionals arguments.  We'll need to dig into that more.
2022-08-04 00:14:41 -05:00
Ed Page
53836f583c fixup! refactor(parser): Clarify where escaping is relevant 2022-08-03 23:53:33 -05:00
Ed Page
69c4628b16 refactor(parser): Remove redundant code 2022-08-03 18:10:45 -05:00
Ed Page
deba6bdda5 refactor(parser): Clarify where escaping is relevant 2022-08-03 17:42:11 -05:00
Ed Page
e6577b284e fix(assert)!: Prevent require equal when it won't work 2022-08-03 17:41:47 -05:00
Ed Page
1352be3d88 fix(parser): Further limit num_args to user values 2022-08-03 17:41:47 -05:00
Ed Page
03f747ba8b fix(parser)!: Only apply num_args to user values 2022-08-03 17:41:42 -05:00
Ed Page
6dddf119ce fix!: num_args controls user args rather than parsed values
This mostly impacts use of delimiters.
2022-08-03 14:45:52 -05:00
Ed Page
ba15b5f430 fix!: Rename Arg::number_of_values to Arg::num_args 2022-08-03 14:45:47 -05:00
Ed Page
0664c6db37 fix!: Remove Arg::use_value_delimiter in favor of Arg::value_delimiter 2022-08-03 11:15:29 -05:00
Ed Page
470531b515 fix!: Replace multiple_values with number_of_values
This reduces ambiguity in how the different "multiple" parts of the API
interact and lowrs the amount of API surface area users have to dig
through to use clap.

For now, this is only a matter of cleaning up the public API.  Cleaning
up the implementation is the next step.
2022-08-01 15:50:23 -05:00
Ed Page
e2a6bbfa95 refactor(parser): Simplify calculation for more values 2022-07-29 15:04:03 -05:00
Ed Page
39e5a86391 fix: Update positional for new num_vals 2022-07-29 15:02:08 -05:00
Ed Page
b47464955c refactor: Switch to getter for number_of_values 2022-07-29 14:51:02 -05:00
David Tolnay
10137fbd33
chore: Delete seemingly stray cargo_example_derive file 2022-08-01 16:54:37 -07:00
Ed Page
8f6231010a
Merge pull request #4015 from epage/arg_enum
fix!: Remove rest of deprecated APIs
2022-08-01 15:34:41 -05:00
Ed Page
76bff6f34e fix!: Remove rest of deprecated APIs
Fixes #4009
2022-08-01 15:21:33 -05:00
Nikhil Thomas
823e5664cd
[Documentation] fix typo in arg.rs 2022-08-01 12:55:04 -04:00
Ed Page
40a9061c26 fix(parser): Include required argument in message
When suggesting required arguments, we wanted to avoid an argument
showing up in both a group and by itself but we didn't correctly
calculate that, causing no required arguments to show up at times.

Now, we all use the same pool of information for doing the calculations.

This was the type of cleanup that I expected it to drop our binary size
but this added 1k to our .text.  Strange.

Fixes #4004
2022-07-29 19:54:32 -05:00
Ed Page
d001952ac4 refactor(usage): Clarify required gathering 2022-07-29 19:23:29 -05:00
Ed Page
81bc351cfc fix(help): Show when a flag 'ArgAction::Count's 2022-07-29 09:56:26 -05:00
Ed Page
ac32c831fc fix(help): Remove '...' for optional values 2022-07-29 09:44:29 -05:00
Ed Page
eee31e2e31 docs: Provide best practice by example 2022-07-28 21:50:32 -05:00
Ed Page
30f5b11d06 fix!: Replaced min_values (tota) with number_of_values (per occurrence) 2022-07-28 21:40:40 -05:00
Ed Page
ccf35ff70c fix!: Replace min_values (total) with number_of_values (per occurrence) 2022-07-28 17:13:41 -05:00
Ed Page
ab8ef46663 fix: arg!(--long [value]) to per occurrence values
Before we did 0..=1 across all occurrences when what we really wanted
was 0..=1 per occurrence.  This makes it compatible with
`ArgAction::Append`.
2022-07-28 16:52:30 -05:00
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
Ed Page
16b0362807 fix(error):! Merge EmptyValue into InvalidValue
There isn't a reason to programmatically differentiate them so this
merges them simplify programamtic cases and to hopefully reduce binary
size.
2022-07-22 09:06:01 -05:00
Ed Page
0902ac71f5 docs: Don't link to removed functions 2022-07-21 17:05:57 -05:00
Ed Page
cf60f84894 fix!: Remove ArgSettings from the API 2022-07-21 16:17:44 -05:00
Ed Page
09c6405d5c fix!: Remove validator 2022-07-21 16:05:39 -05:00
Ed Page
f10809f0cc fix!: Remove possible_values 2022-07-21 15:54:26 -05:00