Commit graph

2872 commits

Author SHA1 Message Date
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
Ed Page
d7618c79af fix!: Remove args_override_self 2022-07-21 15:45:12 -05:00
Ed Page
0405966896 fix!: Remove allow_invalid_utf8 2022-07-21 15:32:10 -05:00
Ed Page
0f3e1b17cf fix!: Remove max_occurrences 2022-07-21 15:26:22 -05:00
Ed Page
137924fe48 fix!: Remove forbid_empty_values 2022-07-21 15:24:25 -05:00
Ed Page
6e1e0f9fa2 fix!: Remove App alias for Command 2022-07-21 15:08:37 -05:00
Ed Page
b94d5fcec0 fix!: Remove renamed deprecated functions 2022-07-21 14:57:55 -05:00
Ed Page
bcad76396b fix!: Remove ErrorKind::ArgumentNotFound
This existed for `value_of_t` and isn't needed anymore
2022-07-21 14:42:34 -05:00
Ed Page
75ebeca6d8 fix!: Remove clap 2.x compatibility functions 2022-07-21 14:34:27 -05:00
Ed Page
cd9cbb4c20 fix!: Remove ArgMatches::*value* functions 2022-07-21 14:24:16 -05:00
Ed Page
d4d21b0f7f fix!: Remove WaitOnError 2022-07-21 13:35:49 -05:00
Ed Page
fc7aa40c87 fix!: Remove Error::info and Error::kind fields 2022-07-21 13:06:11 -05:00
Ed Page
819c1e061d fix!: Remove deprecated macros 2022-07-21 13:03:21 -05:00
Ed Page
57bfb8c425 fix!: Remove usage parser 2022-07-21 12:59:56 -05:00
Ed Page
6428618bf2 fix(derive)!: Remove deprecated trait methods 2022-07-21 12:57:17 -05:00
Ed Page
ff0796b014 fix(derive)!: Remove old derive names 2022-07-21 12:57:12 -05:00
Ed Page
da5d5b8b53 fix!: Remove SubCommand 2022-07-21 12:48:52 -05:00
Ed Page
99d92c916c fix!: Remove yaml support 2022-07-21 12:46:47 -05:00
Ed Page
765af4198c fix!: Remove regex validation 2022-07-21 12:42:09 -05:00
Ed Page
48f087d090 fix(parser): low index multiples work with flags
We had some tests for this but not sufficient obviously.  The problem is
we were tweaking the positional argument counter when processing flags
and not just positional arguments.  Delaying it until after flags seems
to fix this.

Fixes #3959
2022-07-20 17:44:49 -05:00
Ed Page
5e02445ce5 docs: Small tweak to lib docs 2022-07-19 15:54:01 -05:00
Tshepang Mbambo
01d7e7ac04
docs: reduce the need to guess 2022-07-19 22:32:42 +02:00
Ed Page
d43f1dbf6f docs: Move everything to docs.rs
A couple of things happened when preparing to release 3.0
- We needed derive documentation
  - I had liked how serde handled theres
  - I had bad experiences finding things in structopt's documentation
- The examples were broken and we needed tests
- The examples seemed to follow a pattern of having tutorial content and
  cookbook content
- We had been getting bug reports from people looking at master and
  thinking they were looking at what is currently released
- We had gotten feedback to keep down the number of places that
  documentation was located

From this, we went with a mix of docs.rs and github
- We kept the number of content locations at 2 rather than 3 by not
  having an external site like serde
- We rewrote the examples into explicit tutorials and cookbooks to align
  with the 4 styles of documentation
- We could test our examples by running `console` code blocks with
  trycmd
- Documentation was versioned and the README pointed to the last release

This had downsides
- The tutorials didn't have the code inlined
- Users still had a hard time finding and navigating between the
  different forms of documentation
- In practice, we were less likely to cross-link between the different
  types of documentation

Moving to docs.rs would offer a lot of benefits, even if it is only
designed for Rust-reference documentation and isn't good for Rust derive
reference documentation, tutorials, cookbooks, etc.  The big problem was
keeping the examples tested to keep maintenance costs down.  Maybe its
just me but its easy to overlook
- You can pull documentation from a file using `#[doc = "path"]`
- Repeated doc attributes get concatenated rather than first or last
  writer winning

Remember these when specifically thinking about Rust documentation made
me realize that we could get everything into docs.rs.

When doing this
- Tutorial code got brought in as was one of the aims
- We needed to split the lib documentation and the README to have all of
  the linking work.  This allowed us to specialize them according to
  their rule (user vs contributor)
- We needed to avoid users getting caught up in making a decision
  between Derive and Builder APIs so we put the focus on the derive API
  with links to the FAQ to help users decide when to use one or the
  other.
- Improved cross-referencing between different parts of the
  documentation
- Limited inline comments were added to example code
  - Introductory example code intentionally does not have teaching
    comments in it as its meant to give a flavor or sense of things and
    not meant to teach on its own.

This is a first attempt.  There will be a lot of room for further
improvement.  Current know downsides:
- Content source is more split up for the tutorials

This hopefully addresses #3189
2022-07-19 13:30:38 -05:00
Ed Page
a8a7a61f56 chore: Release 2022-07-14 09:38:54 -05:00
Ed Page
afc540153b
Merge pull request #3902 from tmccombs/get-conflicts-with-group
Include groups in `get_arg_conflicts_with`
2022-07-14 09:37:45 -05:00
Thayne McCombs
f27f1f57ea fix: Include groups in get_arg_conflicts_with
So that it doesn't panic if trying to get the conflicts for an Arg that
conflicts with a group.

Fixes: #3900
2022-07-14 01:08:06 -06:00
Ed Page
2df0732df4 chore: Release 2022-07-13 09:08:35 -05:00
Emerson Ford
e39156e0b9 feat: Add method to get non-visible arg aliases 2022-07-12 11:23:22 -07:00