Commit graph

6116 commits

Author SHA1 Message Date
Ed Page
d04ecd41f3
Merge pull request #4097 from epage/possible
fix!: Remove lifetime from PossibleValue
2022-08-19 13:50: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
99d3bb8f74
Merge pull request #4096 from epage/raw
fix: Switch to owned OsStr type
2022-08-19 12:13:27 -05:00
Ed Page
e81b1aace7
Merge pull request #4095 from epage/flag
feat(parser): Make customizeing flags easier
2022-08-19 08:35:03 -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
cf7d78692b
Merge pull request #4092 from epage/flag
fix: Allow non-bool value_parsers for SetTrue
2022-08-18 21:52:31 -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
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
554724f917
Merge pull request #4085 from orhun/docs/fix_typo_in_changelog
Fix typo in CHANGELOG.md
2022-08-16 13:47:51 -05:00
Orhun Parmaksız
97b0feffed
docs: Fix typo in changelog 2022-08-16 20:19:03 +02: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
Ed Page
a42480198b
Merge pull request #4083 from LeSeulArtichaut/doc-typo
docs: fix typo in markdown formatting
2022-08-16 07:57:56 -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
472ede9f10
Merge pull request #4081 from epage/into_iter
fix!: Prefer `IntoIterator` over `&[]`
2022-08-15 14:24:35 -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
Ed Page
c45bd64941 test(builder): Clear up test files names 2022-08-15 09:47:49 -05:00
Ed Page
495e49e1a7
Merge pull request #4075 from cnpryer/faq
Quality improvements to FAQ docs
2022-08-13 21:58:30 -05:00
Ed Page
fb9dca0a0c
Merge pull request #4076 from cnpryer/tutorial-builder
Fix enum example comment
2022-08-13 21:51:15 -05:00
Chris Pryer
8bf39d9275
docs(tutorial): Fix enum example comment 2022-08-13 20:56:27 -04: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
3c82418c8c
Merge pull request #4072 from epage/group
fix(parser)!: Store args in a group, rather than values
2022-08-12 17:00:49 -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
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