Commit graph

6741 commits

Author SHA1 Message Date
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
Ed Page
9036d3fd3c refactor(help): Split out help templates 2022-09-19 11:20:18 -05:00
Ed Page
e75da2f868 perf(help): Reduce colorless code size
This takes off another 14 KiB when color us not used.  My hope is that
we'll be able to switch away from `termcolor` to a term styling crate
that will make this work in the color case as well.
2022-09-19 10:36:43 -05:00
Ed Page
2d83a7b12e feat(error): Break out error-context feature flag
This is a cheap pass at creating this to allow cutting out the cost of
rich error information / programmatic error information.

This cuts about 20 KiB off of the binary.

There is more we could cut out, like collecting of used arguments for
the usage, but I want to keep the conditionals simple.
2022-09-19 10:23:55 -05:00
Ed Page
b4788d51f1 fix(error): Provide a no-context alternative to RichFormatter 2022-09-19 09:48:54 -05:00
Ed Page
ba9e6d052a feat(error): Provide abstraction for default formatter 2022-09-19 09:38:16 -05:00
Ed Page
94c5802aae docs: Update changelog 2022-09-19 09:28:56 -05:00
Ed Page
746481cc56
Merge pull request #4235 from epage/help
fix(help): Separate command flags like options
2022-09-19 09:22:00 -05:00
Ed Page
f7dfb573ff
Merge pull request #4230 from sashashura/patch-5
fix: Permissions syntax
2022-09-19 09:15:04 -05:00
Ed Page
e9f1287b63 fix(help): Separate command flags like options
Fixes #4232
2022-09-19 09:07:43 -05:00
Ed Page
ad05d1624b fix(help: Be more precise on literal vs not 2022-09-19 09:05:44 -05:00
Alex
e03201efbe
fix: Permissions syntax 2022-09-18 18:55:47 +01:00
Ed Page
574641ac63
Merge pull request #4225 from sashashura/patch-3
Update audit.yml
2022-09-17 14:36:42 -05:00
Alex
efc49747e7 chore: Update audit.yml 2022-09-17 15:22:06 +03:00
Ed Page
6dc8c9943c
Merge pull request #4223 from epage/string
perf: Switch to &'static str by default
2022-09-16 17:06:04 -05:00
Ed Page
1365b08849
Merge pull request #4222 from epage/size
fix: Misc fixes found when optimizing code size
2022-09-16 16:48:23 -05:00
Ed Page
c165b601ac perf: Switch to &'static str by default
Originally, clap carried a lifetime parameter.  When moving away from
that, we took the approach that dynamically generated strings are always
supported and `&'static str` was just an optimization.

The problem is the code size increase from this is dramatic.  So we're
taking the opposite approach and making dynamic formatting opt-in under
the `string` feature flag.  When deciding on an implementation, I
favored the faster one rather than the one with smaller code size since
small code size can be gotten through other means.

Before: 567.2 KiB, 15.975 µs
After: 541.1 KiB, 9.7855 µs
With `string`: 576.6 KiB, 13.016 µs
2022-09-16 16:44:39 -05:00
Ed Page
fe43f0c945 Revert "fix: Remove once_cell dependency from derive"
This reverts commit 429143af42.
2022-09-16 16:19:03 -05:00
Ed Page
bbbaca2ffe perf: Hint to the compiler when once_cell isn't needed 2022-09-16 16:14:32 -05:00
Ed Page
10854cd262 Revert "refactor: Remove once_cell dependency"
This reverts commit c9d883a8c6.
2022-09-16 16:14:32 -05:00
Ed Page
7ccaebb65d refactor(parser): Switch from Box<str> to String
This is a more familiar type for people and it didn't cost us anything
(in fact it undid the code size change in the last commit).
2022-09-16 16:14:32 -05:00
Ed Page
1e13109a26 refactor(parser): Track subcommands with Box<str>
The overall hope is to allow a `&'static str`-only version of clap, so
we need to move off of `Str` where dynamic strings are required.  We
need it here for subcommands due to external subcommands.

This had minimal impact on code size (567.2 to 567.5 KiB)
2022-09-16 16:14:32 -05:00
Ed Page
86b2fe5a2d refactor(parser): Reduce work when validating args 2022-09-16 16:14:16 -05:00
Ed Page
af9e1b9763 refactor(parser): Don't throwaway work 2022-09-16 16:14:16 -05:00
Ed Page
4869c43612 refactor: Simplify help subtree creation 2022-09-16 16:14:16 -05:00
Ed Page
3cadb8f255 docs(tutorial): Provide better default_value_t example 2022-09-16 16:14:16 -05:00