Ed Page
3a8d2a579b
test(parser): Verify existing --flag=bad-value case
2022-09-27 09:19:27 -05:00
Ed Page
f925ca84b6
docs: Clarify how to use examples
...
When we restuctured the examples, we lost the notes on how they should
be structured, so this adds it back in.
2022-09-26 21:06:02 -05:00
Ed Page
a0c8c7dbd5
docs: Clean up StyledStr entries
2022-09-26 13:51:56 -05:00
Ed Page
01672f8359
chore: Release
2022-09-26 13:42:34 -05:00
Ed Page
a5ce7a0187
Merge pull request #4262 from epage/conflict
...
fix(parser): Conflict-with-self is back on by default
2022-09-26 13:41:45 -05:00
Ed Page
9bccded7ed
fix(parser): Conflict-with-self is back on by default
...
See #4261 for more details
2022-09-26 13:29:48 -05:00
Ed Page
7998669219
Merge pull request #4259 from epage/try
...
perf: Drop use of Into::into for '?'
2022-09-26 12:48:39 -05:00
Ed Page
4a1552cc0e
perf: Drop use of Into::into for '?'
...
For binary size, this only dropped 0.2 KiB
For performance, before:
- parse_rustup_with_sc time: [7.9866 µs 8.0138 µs 8.0470 µs]
After:
- parse_rustup_with_sc time: [7.5387 µs 7.5722 µs 7.6157 µs]
For build-time, before
```console
$ hyperfine --warmup=1 --min-runs=5 "--prepare=cargo clean" "cargo build -F cargo --example cargo-example"
Benchmark 1: cargo build -F cargo --example cargo-example
Time (mean ± σ): 16.988 s ± 1.190 s [User: 68.178 s, System: 6.637 s]
Range (min … max): 15.550 s … 18.277 s 5 runs
```
After:
```console
$ hyperfine --warmup=1 --min-runs=5 "--prepare=cargo clean" "cargo build -F cargo --example cargo-example"
Benchmark 1: cargo build -F cargo --example cargo-example
Time (mean ± σ): 15.674 s ± 0.222 s [User: 62.287 s, System: 4.608 s]
Range (min … max): 15.426 s … 15.993 s 5 runs
```
2022-09-26 12:31:39 -05:00
Ed Page
c4b3a4f491
refactor: Remove use of '?'
2022-09-26 12:19:30 -05:00
Ed Page
18ed37ee67
Merge pull request #4258 from epage/features
...
fix(help)!: Wrapping is behind wrap_help
2022-09-26 12:01:24 -05:00
Ed Page
3c9bca5ead
fix(help)!: Wrapping is behind wrap_help
...
If users don't want `wrap_help` feature, they can put newlines in where
needed. Seems odd to support wrapping when the wrap size is fixed. For
those hard coding the lines, this will save them a decent amount of
size.
2022-09-26 11:45:44 -05:00
Ed Page
bac3eb3280
docs: Raise visibility of 'string' feature
2022-09-26 11:14:06 -05:00
Ed Page
2f93c1790f
docs: Help migrate with default features
2022-09-26 11:11:55 -05:00
Ed Page
3772bdf041
docs: Update changelog
2022-09-26 11:08:59 -05:00
Ed Page
c5c3c00735
Merge pull request #4257 from epage/os_str
...
feat(parser): Support more types with `value_parser!`
2022-09-26 10:50:14 -05:00
Ed Page
bd6b67c605
style: Make clippy happy
2022-09-26 09:55:02 -05:00
Ed Page
31f9234cc7
feat(parser): Add From<str> and From<String>
2022-09-26 09:51:44 -05:00
Ed Page
931b6338f1
refactor(parser): Clarify FromStr from future FromStr
2022-09-26 09:51:03 -05:00
Ed Page
76ec238b45
docs: Clarify value_parser implementation
2022-09-26 09:50:51 -05:00
Ed Page
9f49c0c630
feat(parser): Support From<OsString> for value_parser
2022-09-26 09:50:49 -05:00
Ed Page
e64ed91a4e
feat(parser): Support From<&OsStr> types for value_parser!
...
Last time I tried this, I wasn't able to resolve the lifetime issues. I
seemed to have gotten it working this time.
This came up in #4254 .
2022-09-26 09:50:12 -05:00
Ed Page
0380d8deca
Merge pull request #4248 from epage/ansi
...
feat: Allow users to render usage, help, and errors with ANSI
2022-09-22 10:16:39 -05:00
Ed Page
037b07577c
feat: Expose ANSI styling to the user
...
This gives users the control over where clap outputs while still getting
colors. For users who want to support old windows versions, check out
`fwdansi` crate.
2022-09-22 09:59:42 -05:00
Ed Page
a2272a2c50
feat(error): Add a 'render' method
2022-09-22 09:55:11 -05:00
Ed Page
4280fdfcbd
fix(help): Replace help writers with renderers
...
The writer is less convenient and isn't offering any performance
benefits of avoidign the extra allocations, so let's render instead.
This supersedes #3874
Fixes #3873
2022-09-22 09:54:19 -05:00
Ed Page
652e71d616
fix(help)!: Provide styled usage to user
...
This will open us up to providing the user with access to the styled
version in the future.
2022-09-22 09:54:19 -05:00
Ed Page
8e510650a9
Merge pull request #4247 from YC/master
...
doc(changelog): error-context, help and usage feature flags
2022-09-22 07:04:37 -05:00
Steven Tang
e5ced8bae6
docs: Changelog - error-context, help, usage flags
2022-09-22 21:11:19 +10:00
Ed Page
a76f622d17
docs: Clarify when quoting is required for arg
2022-09-21 11:49:18 -05:00
Ed Page
b44dbdf09d
chore: Release
2022-09-21 11:35:10 -05:00
Ed Page
32637d4d09
Merge pull request #4244 from epage/docs
...
docs: Clarify value parser
2022-09-21 11:34:38 -05:00
Ed Page
2bbb81f311
docs: Clarify value parser
...
Things that tripped up a user
- Derive reference was misunderstood to say that the only alternative to
the built-in value parser behavior was to implement
`ValueParserFactory`
- We now delegate to `value_parser!`s docs any talk of integrating
into it (it should have been a subbullet of "not present" anyways)
- `value_parser!` relies too much on the example to demonstrate behavior
when the user will likely make the determination of whether its
relevant before then
- We are now more upfront what type mappings are supported
- Too many steps to find all information
- For example, a user needs to look at `TypedValueParser`
implementations, `ValueParserFactory` implementations, and `From<T>
for ValueParser` implementations to understand what all can be used
- We are now more upfront with a lot of this information at the entry
points the user is most likely to look at
In addition, I did an audit of the docs to make sure they were updated
for us only supporting the new behavior and all of the new APIs.
See https://www.reddit.com/r/rust/comments/xjlie4/preannouncing_clap_40_a_rust_cli_argument_parser/ip9kzf1/
2022-09-21 11:11:21 -05:00
Ed Page
99dfe7404a
docs(ref): Remove dead example
...
This was missed in the migration to the reference being on docs.rs. Not
feeling its worth finding a way to integrate it into the new structure.
2022-09-21 11:02:08 -05:00
Ed Page
16c46b4b3b
chore: Release
2022-09-20 16:32:10 -05:00
Ed Page
a82029c707
chore: Release
2022-09-20 16:30:29 -05:00
Ed Page
af64699912
chore: Release
2022-09-20 16:28:27 -05:00
Ed Page
21e1cf039b
docs(lex): Update changelog
2022-09-20 16:28:14 -05:00
Ed Page
f27769810e
Merge pull request #4240 from tshepang/patch-1
...
docs: a comma felt wrong there
2022-09-20 16:21:23 -05:00
Ed Page
b0027b5943
docs: Further clarify the text
2022-09-20 16:21:10 -05:00
Tshepang Mbambo
a6822a27b4
a comma felt wrong there
2022-09-20 23:09:19 +02:00
Ed Page
ba56ac770c
Merge pull request #4239 from epage/alias
...
fix(error): Use a non-generic Error alias
2022-09-20 14:11:21 -05:00
Ed Page
4674e43493
fix(error): Remove RawFormatter
...
The likelihood of using this is a lot lower now with `KindFormatter` and
`error-context` feature flag.
People can implement it themselves.
2022-09-20 13:40:18 -05:00
Ed Page
90bcb7f75e
fix(error): Use a non-generic Error alias
...
`clap::Error::raw` was producing ambiguity errors with a default generic
parameter on `clap::error::Error` (which `clap::Error` is a re-export
of).
I tried making `clap::Error` a type alias with a default generic
parameter but that ran into an ambiguity error with `map_err`.
So I'm going ahead and hard coding `clap::Error`. We don't expect
people to change this all that often.
2022-09-20 13:37:02 -05:00
Ed Page
c26e7fd617
Merge pull request #4236 from epage/usage
...
feat: Allow turning off error-context, auto-help, and auto-usage
2022-09-19 14:16:37 -05:00
Ed Page
745fa9927a
perf(help): Remove more from usage feature
...
Quality of error-context goes down with this.
2022-09-19 14:03:55 -05:00
Ed Page
bfa365a2cc
feat(help): 'usage' feature flag for auto-genned usage
2022-09-19 13:15:47 -05:00
Ed Page
80f616a4b3
refactor(parser): Clarify argument
2022-09-19 13:02:26 -05:00
Ed Page
553a93efc8
refactor(help): Make usage optional
2022-09-19 12:15:52 -05:00
Ed Page
7a5dad89ff
feat(help): Break out help feature flag
...
This removes auto-generated help, saving about 50 KiB.
2022-09-19 11:54:10 -05:00
Ed Page
6ea5d46300
refactor(help): Move near use
2022-09-19 11:26:06 -05:00