Commit graph

6080 commits

Author SHA1 Message Date
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
a5494573af chore(ci): Lock docs to MSRV
This will help avoid issues with new warnings
2022-08-12 08:24:15 -05:00
Ed Page
14b70597c0
Merge pull request #4067 from epage/clippy
style: Address clippy
2022-08-12 08:22:57 -05:00
Ed Page
43e961d24f style: Address clippy 2022-08-11 16:07:58 -05:00
Ed Page
084a6dffeb
Merge pull request #4065 from epage/flat
refactor: Move off of HashMap/IndexMap to flat containers
2022-08-11 14:47:54 -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
b344f1cf18
Merge pull request #4060 from epage/msrv
chore: Bump MSRV to 1.60.0
2022-08-11 09:06:56 -05:00
Ed Page
1c06735390 chore: Update dependencies 2022-08-10 21:49:22 -05:00
Ed Page
6bc8dfd32b
Merge pull request #4059 from epage/no-implicit
fix: No implicit version/help actions
2022-08-10 21:48:07 -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
1a08b9184b
Merge pull request #4056 from epage/help
fix!: Require explicit help/version disabling
2022-08-10 20:46:51 -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
0129d99f4c
Merge pull request #4055 from epage/clippy
style: Make clippy happy
2022-08-10 11:57:09 -05:00
Ed Page
64639aa81c style: Make clippy happy 2022-08-10 11:41:27 -05:00
Ed Page
c7d9fec2f8
Merge pull request #4054 from epage/help
fix(debug): Make it easier to address help issues
2022-08-10 09:30:04 -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
Ed Page
a98bcb4d13
Merge pull request #4049 from danielparks/issue-3785-derive-id-attr
fix(derive): Add "id" attribute
2022-08-09 14:31:45 -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
6aa4f90609
Merge pull request #4045 from epage/enum
docs(tutorial): Switch to hand-implemented ValueEnum
2022-08-09 11:30:23 -05:00
Ed Page
2d352cb16f docs: Clarify intention for new APIs 2022-08-09 10:23:23 -05:00
Ed Page
36777e7b6c docs(tutorial): Switch to hand-implemented ValueEnum 2022-08-09 10:23:23 -05:00
Ed Page
1c3159700d docs(contrib): Say why we use feature flag 2022-08-09 10:23:23 -05:00
Ed Page
78b2b44b95 docs(tutorial): Focus on actions, not macros 2022-08-09 10:23:23 -05:00
Ed Page
52f039e549
Merge pull request #4044 from epage/v4
docs: v4-specific improvements
2022-08-08 20:47:04 -05:00
Ed Page
571e3a5e15 docs(tutorial): Use arg!s action selection 2022-08-08 14:36:29 -05:00
Ed Page
f3d4c2c971 docs(derive): Remove clap v3 caveats 2022-08-08 14:15:00 -05:00
Ed Page
e1aafce431 test(tutorial): Ensure we actually test code
Biggest problem identified is that we are incorrectly setting the help
usage in `04_04_custom`
2022-08-08 14:05:08 -05:00
Ed Page
179faa6bb2
Merge pull request #4032 from epage/flag
fix!: Make ArgAction::Set the default
2022-08-05 19:22:50 -05:00
Ed Page
69ad5cfd84 test(derive): Highlight current behavior for version/help 2022-08-05 14:22:09 -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
58b0529d13
Merge pull request #4031 from epage/multiple
refactor: We don't need MultipleValues for bookkeeping afterall
2022-08-04 17:51:45 -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
fcbcafcd74
Merge pull request #4030 from epage/take
fix!: Remove bookkeeping getters from API
2022-08-04 16:02:47 -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