Commit graph

2389 commits

Author SHA1 Message Date
Ed Page
cd6e009c83 refactor: Reduce visibility of ArgMatcher members 2022-02-01 11:27:08 -06:00
Ed Page
4538d618a7 refactor: Migrate off of .kind 2022-02-01 11:27:08 -06:00
Ed Page
65c9bba85c feat(error): Provide kind()
This is prep for deprecating direct member access but not doing it yet.
2022-02-01 11:27:08 -06:00
Ed Page
7f61869a60 refactor: Reduce visibility on Error members 2022-02-01 11:27:08 -06:00
Jan Verbeek
bfc8e8d367 perf: Do not instantiate Id::from(&&str)
Saves 0.3K.
2022-02-01 17:22:03 +01:00
Jan Verbeek
9e625c0c55 perf: Avoid clone 2022-02-01 17:22:03 +01:00
Jan Verbeek
d1d9f75d53 perf: Make formatting method calls more efficient
If a value must be reused later then it's better to pass it as a &str
instead of cloning it, that means the clone happens in a central
place (inside the method).

By never passing a &String those instances of the method are not monomorphized.

Saves only 0.5K, maybe not worth it in hindsight.
2022-02-01 17:22:03 +01:00
Jan Verbeek
54e8f7eff2 perf: Extract common Error constructor logic
Saves 1.2K.
2022-02-01 17:21:57 +01:00
Jan Verbeek
b2cc41884d style: Use clearer variable name for formatted verb 2022-02-01 17:21:57 +01:00
Jan Verbeek
0dce4b5af2 perf: Split delimited value in single iterator
Saves 0.9K.
2022-02-01 17:21:52 +01:00
Jan Verbeek
9b03495bc6 perf: Format directly into strings
Saves 0.5K (and some allocations).
2022-02-01 17:21:52 +01:00
Jan Verbeek
4420fd25c8 perf: Merge .clone() calls
This seems like something rustc would be able to figure out, but
apparently not.

Saves 0.6K.
2022-02-01 17:21:52 +01:00
Jan Verbeek
6411e2ede6 style: Change format!("{}") → to_string() 2022-02-01 17:21:47 +01:00
Jan Verbeek
2d340dce9e perf: Prefer write_str() over write!("{}")
Saves 1K.
2022-02-01 17:21:47 +01:00
Jan Verbeek
778bcf2ecc perf: Extract non-generic part of App::new()
Saves 5K.
2022-02-01 17:21:47 +01:00
Jan Verbeek
7774a8ee8a perf: Do not clone subcommands
This saves a whopping 8K. I suspect it allows two sorting functions
to be merged.
2022-02-01 17:21:47 +01:00
Jan Verbeek
c77fb2e11d perf: Remove unnecessary clone 2022-02-01 17:21:47 +01:00
Jan Verbeek
14f9ec0ab6 style: Avoid nested unwrap_or 2022-02-01 17:21:47 +01:00
Jan Verbeek
14fa6a73fa perf: Avoid unnecessary String
Saves 0.3K.
2022-02-01 17:21:47 +01:00
Jan Verbeek
b4a2966e51 style: Convert char to string in single operation 2022-02-01 17:21:47 +01:00
Jan Verbeek
b5a8f828b8 style: Use if instead of strange Option::map_or 2022-02-01 17:21:47 +01:00
Jan Verbeek
21f0cd5662 perf: Avoid double reference 2022-02-01 17:21:47 +01:00
Jan Verbeek
0b3ad1735a perf: Avoid unnecessary copies in errors
Saves 3.5K.
2022-02-01 17:21:40 +01:00
Jan Verbeek
6d558c9141 perf: Do not inline get_color()
Saves 1.7K.
2022-02-01 17:21:40 +01:00
Jan Verbeek
3258396738 perf: Do not do verb formatting at runtime
Saves 1K.
2022-02-01 17:21:40 +01:00
Jan Verbeek
0c0d51b29a perf: De-inline another formatting method 2022-02-01 17:21:40 +01:00
Jan Verbeek
82dd01a1df style: Change unwrap_or_else() → or() 2022-02-01 17:21:35 +01:00
Jan Verbeek
29191bf386 perf: Remove another BTreeMap
This is smaller if we do a stable sort.
2022-02-01 00:02:44 +01:00
Jan Verbeek
844e0cde91 perf: Improve display_arg_val() code size
Making it non-generic doesn't seem to help.
2022-02-01 00:02:44 +01:00
Jan-Bernd Vosteen
c78494fd75 added missing 'be' 2022-01-31 14:52:36 +01:00
Wilfred Hughes
f7a2b472a2
Fix typo in doc comment 2022-01-29 16:18:33 -08:00
Jan Verbeek
a18658af86 perf: Replace BTreeMaps by manually sorted Vecs
This removes another ~20KB of code size.

There is one BTreeMap left, but replacing that one doesn't make a difference.
2022-01-29 22:18:32 +01:00
Jan Verbeek
7bf2479125 perf: Do not inline formatting methods
This shaves off ~20KB from the argparse-benchmarks-rs app.
2022-01-29 22:18:30 +01:00
Sondre Nilsen
0b045f5d0d
feat(man): Initial man generator (#3174)
This is an initial implementation with plenty of room to grow, including
- Allowing pulling out a subset of the generated man page for greater customization
- Subcommand handling
- Extra sections
- Consolidate argument formatter after #2914

Fixes #552
2022-01-28 14:55:55 -06:00
Ed Page
d2109b3969 chore: Release 2022-01-26 15:54:12 -06:00
Peter Grayson
7eea7d27ad
fix(help): Optional arg values in brackets
When an Arg uses .min_values(0), that arg's value(s) are effectively
optional. This is conventionaly denoted in help messages by wrapping the
arg's values in square brackets. For example:

    --foo[=value]
    --bar [value]

This kind of argument can be seen in the wild in many git commands; e.g.
git-status(1).

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2022-01-26 12:03:23 -05:00
Ed Page
ea7699c11f chore: Release 2022-01-24 15:34:27 -06:00
Ed Page
e5b06c3061 chore: Release 2022-01-24 10:54:50 -06:00
Ed Page
c6664afe9d fix(parser): Track the most explicit value source
We were only tracking the last value source (default, env, cli, etc).
This works for args because they only come from one source.  Groups
however can come from multiple sources and this was making us treat a
group with a default value as being completely from defaults despite
some values maybe being from the commandline.

We now track the highest precedence value for a group.

Fixes #3330
2022-01-24 10:34:41 -06:00
Ed Page
43673a1bd1 docs(error): Update reported failure code
Fixes #3332
2022-01-24 08:11:18 -06:00
Ed Page
5877f884f1 chore: Release 2022-01-18 14:59:58 -06:00
Ed Page
38e6952d46 fix: Don't panic when propagating
I thought I was adding a test in #3305.  Maybe I considered the
clap_complete changes sufficient for this.  Doing more `debug_assert`s
would be good also.

Unsetting `PropagateVersion` helps in some cases but we need to unset it
globally to override the global propagation.

Fixes #3310
2022-01-18 14:38:58 -06:00
Ed Page
bd1bf66279 chore: Release 2022-01-17 20:34:09 -06:00
Rain
236ec973d9 feat: Implement App::find_subcommand_mut
Similar to `App::find_subcommand`, except it returns a mutable reference
to the subcommand.
2022-01-17 12:31:41 -08:00
Ed Page
ccbbba8908 chore: Release 2022-01-17 09:37:45 -06:00
Ed Page
ffe6bff8ac
Merge pull request #3305 from epage/help
fix(help): Always respect DisableColoredHelp
2022-01-17 09:35:18 -06:00
Ed Page
4a43b51a42 fix(complete): Handle help completions
The main motivation was to reduce special cases by putting all of the
logic in one place.
2022-01-17 09:23:04 -06:00
Ed Page
e962ad8ce6 fix(help): Always respect DisableColoredHelp
We might be able to handle version/help before propagation but I didn't
want to hold up this fix for that to happen and increase the risk
associated with this fix.

Fixes #3298
2022-01-17 09:14:07 -06:00
Ed Page
807ddbbb70 refactor: Build help subcommand separately 2022-01-17 08:36:37 -06:00
Ed Page
729f4e7e82 refactor: Make subcommand propagation reusable 2022-01-17 08:33:07 -06:00
Ed Page
3620cad5fa
Merge pull request #3297 from kornelski/track_asserts
Track caller on methods using assertions
2022-01-17 08:00:42 -06:00
Zhishi
fbbd70ccc9 docs: Fix mismatched ` 2022-01-17 19:06:22 +08:00
Kornel
0121690f9c Track caller on methods using assertions 2022-01-16 12:45:25 +00:00
Ed Page
3d8ce3f426 chore: Release 2022-01-12 11:12:42 -06:00
Ed Page
b200a869b4
Merge pull request #3288 from epage/assert
fix: Run more parse asserts during build
2022-01-12 11:09:16 -06:00
Ed Page
b98e8ec24f docs(derive): Args doesn't derive IntoApp
Fixes #3284
2022-01-12 10:58:35 -06:00
Ed Page
de275e7cf9 fix: Run more parse asserts during build
This will help prevent issues from being deployed to users like in #3281

I do not consider this a breaking change because any normal operation
will assert anyways.
2022-01-12 10:55:55 -06:00
Ed Page
811fd6a04a chore: Release 2022-01-10 16:16:18 -06:00
Ed Page
ef823bbeaf chore: Release 2022-01-05 16:28:24 -06:00
Ed Page
faf3861bf1 fix(parser): Loosen asserts for now
This is a surgical workaround for #3263.  It makes `cargo` pass tests!
2022-01-05 16:07:39 -06:00
Ed Page
e9f6ef6638 fix(parser): Fix more panic quotes 2022-01-04 16:10:26 -06:00
Ed Page
2b2e2c9a80 fix(parser): Fix quoting in panic
We ended up with an extra quotation mark that was left unmatched.  Got a
bit confused when I saw this.
2022-01-04 15:52:14 -06:00
Dominik Boehi
ae55a9da68
Correct replacement function for Parser::from_clap 2022-01-04 22:29:39 +01:00
Ed Page
4ea1965789 chore: Release 2022-01-04 13:07:10 -06:00
Ed Page
7e4cd43620 feat(parser): Allow users to avoid undefined arg asserts
Cargo is an example of a user that heavily relied on using undefined
names because there is a lot of code sharing between commands.  This
allows a path forward for those users that is just painful enough to
discourage overly relying on it in the future :).
2022-01-04 12:53:03 -06:00
Ed Page
9daefba196 chore: Release 2022-01-04 11:42:50 -06:00
Ed Page
91de3eb0cd fix: Clarify cause of debug asserts
Ran into one of these being a pain with porting cargo.
2022-01-04 11:30:33 -06:00
Ed Page
d9906eb150 chore: Release 2022-01-04 09:49:41 -06:00
Ed Page
fa5daf4039
Merge pull request #3250 from epage/hyphen
fix(parser): Ignore Last when checking Hyphen Values
2022-01-04 09:46:59 -06:00
Daniel Eades
e8516a9098 style: allow unused field 2022-01-04 09:20:34 -06:00
Daniel Eades
35d7841211 style: simplify boolean expressions 2022-01-04 09:20:30 -06:00
Daniel Eades
e1b21784a0 fix: add 'must_use' attributes to methods returning 'Self' 2022-01-04 09:20:24 -06:00
Daniel Eades
021b1f6997 style: remove useless conversions 2022-01-04 09:20:21 -06:00
Daniel Eades
7f71d642cd style: prefer 'char' to 'str' for single character patterns 2022-01-04 09:20:08 -06:00
Ed Page
15704dcaff fix(parser): Ignore Last when checking Hyphe Values
This was found with #3249
2022-01-04 09:16:03 -06:00
Ed Page
e6ee585a4b fix: Clarify short rejection in debug 2022-01-04 09:00:13 -06:00
Ed Page
d392b88bd5 chore: Release 2022-01-03 12:12:28 -06:00
Ed Page
e5806830f3 fix: Don't panic when getting number of values
I was tempted to remove the exact-size nature.  Wouldn't be breaking
since it only panics but decided to go ahead and do this for now.

Fixes #3241
2022-01-03 11:53:59 -06:00
Ed Page
c01ebbac17 chore: Release 2021-12-31 14:35:02 -06:00
Ed Page
bc951e4e53 chore: Release 2021-12-31 13:37:28 -06:00
Ed Page
8d73a0e80f chore: Release 2021-12-31 12:23:47 -06:00
Ed Page
88a335ff97 fix(complete): Give crates more specific names
`clap_generate` originally intended to be "generate anything".  With
`fig`, we already broke one part out.  With #3174's man support, we are
also looking at keeping it separate:
- More freedom to iterate on the API
- Uniqueness (and potential weight) of its dependencies
- man generation is normally more for distribution while completions are
  a mix of being distributed with the app or the app generating the
  completions (which will be exacerbated if we move most completion
  parsing logic to be in Rust)

So `clap_generate` is having a lot more limited of a role than the
original name conveys.   I worry the generic name will be a hindrance to
people discovering and using it (yes, documentation can help but there
are limits).

I hesitated because we are on the verge of releasing 3.0. However, doing
it even later will be even more disruptive because more people will be
using it (crates.io lists ~70 people using `clap_generate`).

To ease things, we are still releasing `clap_generate` as a wrapper
around `clap_complete`.
2021-12-31 12:03:29 -06:00
Ed Page
2d7dc1ff8f chore: Release 2021-12-30 15:00:19 -06:00
Ed Page
29d4508e2a docs(derive): Link to ref from traits
This is to help with #3189
2021-12-30 14:41:26 -06:00
Ed Page
889a70ebac fix(help): Prefer short version over long version
When we got #3193, we decided in #3196 that `--help` will give a summary
for other commands (`subcmd --help` in this case) but not show the long
version of the output for that other command.

Now with #3215, I think the case is similar for `--help` not showing the
long version but instead preferring the short version and encouraging
people to run `--version`.

Originally. clap only showed the short version or nothing.  This was
changed in #2369 without fanfare to prefer the long version over short.
Now are we preferring short version over the long version always, just
like all other help.

Fixes #3215
2021-12-30 12:21:19 -06:00
Ed Page
e5fbdc9b95 Revert "Remove {n} support"
This reverts commit 333b993481.

PR #1810's motivation was effectively "this is redundant with `\n`".
That is a fine motivation.  Unfortunately, we don't have a way to force
a hard break in `clap_derive`.  #2389 should help with this eventually
but we shouldn't hold up 3.0 to get that ready.  So in the mean time, we
are restoring `{n}`.

We have #3230 for tracking the re-removal of it.
2021-12-30 11:44:45 -06:00
Ed Page
771a44bcef fix: Remove overriden occurrences as we go
This allows two overriding args to interact with each other mid-line.
This was broken in 7673dfc / #1154.  Before that, we duplicated the override
logic in several places.

Now we plug into the start of a new arg which allows us to do this
incrementally without making the logic complex or inefficient, thanks to
prior refactors.

Fixes #3217
2021-12-27 15:32:37 -06:00
Ed Page
c54ea7f4c4 refactor: Propagate AllArgsOverrideSelf during build
This will have a slight performance hit as `AllArgsOverrideSelf` will
allocate a single-element `Vec` per `Arg`.  This can be lessened for
positional and multiple occurrences by shifting those checks up into the
propagation check.

Long term, I'd like to see all of the `Arg`-in-`App` settings switch to
this which will make it easier for callers, like completions and man
pages, to figure out whats going on without duplicating the logic.

Short term, this is motivated by wanting to change the override logic to
accomodated interleaved overrides from #3217.  Moving this logic will
make it easier to change the override logic.
2021-12-27 15:04:07 -06:00
Ed Page
cb393e4439 refactor: Always inc occurrences before adding values
This is the logical order people think in terms of (`--foo` comes before
`val` in `--foo val`). This also opens things up for using occurrence
incrementing as a place to handle occurrence transitions, like
overrides.
2021-12-27 15:03:02 -06:00
Ed Page
d7f27e8732 refactor: Harden against occur/val ordering
This makes some naming more explicit and allows us to increment
occurrences before adding values (which is the logical mental order and
allows other improvements).
2021-12-27 14:50:50 -06:00
Ed Page
2d1dfae318 refactor: Clarify MatchArg::all_val_groups_empty 2021-12-27 14:21:04 -06:00
Ed Page
3db09f4dd4 fix: Don't panic on lack of conflicts
Fixes #3197
2021-12-23 13:38:23 -06:00
Ed Page
02f4ff2115 refactor: Allow more conflicts to be reported 2021-12-23 11:18:22 -06:00
Ed Page
f24b9f50de refactor: Make it easier to get groups 2021-12-23 11:15:11 -06:00
Ed Page
ad127fcc53
Merge pull request #3205 from epage/unless
fix: Ensure we validate required-unless
2021-12-23 08:47:23 -06:00
Ed Page
895e85714b chore: Remove the TODO chaff
The intent is to make stand out more the important technical debt hidden
in comments.
2021-12-22 10:15:09 -06:00
Ed Page
88c927aad3 refactor: Clarify validator relationships
We were storing data off into the struct, obscuring the direct
relationship between gathering and validating conflicts.

With this, not as much code needs to deal with mutable data
2021-12-22 09:14:39 -06:00
Ed Page
2e73be43f1 fix: Ensure we validate required-unless
Found this when digging into #3197
2021-12-21 20:41:17 -06:00
Ed Page
2d462cd0b5 fix(debug): Refer to correct function 2021-12-21 20:35:23 -06:00
Ed Page
318b7859dc fix(help): Don't infer long help from subcommands
Fixes #3193
2021-12-17 09:25:00 -06:00
Ed Page
b4fbd05196 docs(derive): Call out need for derive feature
And other derive tweaks.  I'm mixed on how far to go, including
- Linking to the derive reference
- Showing how to use each trait with both the derive and builder APIs

For now, this is an improvement.
2021-12-16 12:05:52 -06:00
Ed Page
d14255dc00 docs: Show features in docs.rs
Confirmed this works with [`argfile`](https://docs.rs/argfile/latest/argfile/)

And then running in clap
```
$ RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
```
They now show up!
2021-12-16 10:38:31 -06:00
Ed Page
dee3adbd34 fix: Loosen lifetimes on PossibleValue 2021-12-16 09:07:05 -06:00
Ed Page
9e64387ef0 revert(help): Partial revert of 3c049b4
The extra whitespace was targeted at machine processing for a subset of
users for a subset of runs of CLIs.  On the other hand, there is a lot
of concern over the extra verbose output.

A user can set the help template for man, if desired.  They can even do
something (env? feature flag?) to make it only run when doing man
generation.  We also have #3174 in the works.

So let's focus on the end-user reading `--help`.  People wanting to use
`help2man` have workarounds to do what they need.

Fixes #3096
2021-12-15 10:36:59 -06:00
Ed Page
80f426af49 feat!: Allow resetting abouts/help to default
I dislike the inconsistency with only a few fields providing this (this
and `help_heading`) but this is to address a specific bug.  We need to
visit this, along with iterators (#2870) and string handling (#2150).

`Arg` came along for the ride because the derive logic is applied to
both.  `PossibleValue` didn't need it because we filter out `long_help`.

BREAKING CHANGE: We changed the signatures for `App::about`,
`App::long_about`, `Arg::help`, and `Arg::long_help` from accepting
anything `Into<&str>` to `&str`.
2021-12-14 11:07:39 -06:00
Ed Page
19ed78c64f fix(help): Don't commit to '--help' that doesn't work
We have two ways of fixing this
- Making `--help` work
- Don't put `--help` in the help output

For now, I went with the latter.  I tried to make it clear what the
actual requirement is so we can pivot if needed.

Fixes #2892

This happens to also fix the interaction of `DisableHelpFlag` with the
help subcommand and complcations.  I've added a test to help catch if we
break this by changing how we fixed the original issue.

Fixes #2724

These issues were reported against clap3.  I've not tried to reproduce
these in clap2 to see if they should show up in the release notes.
2021-12-13 15:59:14 -06:00
Ed Page
fa439d4f27
Merge pull request #3168 from epage/error
Ensure trailing newlines at the end of errors
2021-12-13 14:15:22 -06:00
Ed Page
a72e5726f8 fix(error): Ensure newline on value_of_t not found
Found this when auditing for cases related to #2787.
2021-12-13 13:30:32 -06:00
Ed Page
2eb69def4e fix(error): Ensure trailing newline without help
Fixes #2787
2021-12-13 13:09:48 -06:00
Ed Page
98a1c2e6c9 fix!: Allow adding new enum variants
Without being a breaking change.

This seems minor enough that we can break this during the release
candidates.  For `ValueHint`, the completion scripts are 99% of who
should be `match`ing it.  `AppSettings` as undocumented variants that
people shouldn't use.

BREAKING CHANGE: `clap::{ValueHint, ErrorKind, AppSettings,
ArgSettings}` are now `non_exhaustive`.
2021-12-13 12:11:00 -06:00
Ed Page
be223df828 fix(ci): Correct release lints
I'm assuming we won't have a negative performance impact by removing
`impl Copy for Id` because the compiler would inline the `clone()`s and
turn them into copies.

Addresses problems from #3164
2021-12-13 09:41:22 -06:00
Ed Page
b55ffdd0ce
Merge pull request #3154 from rhysd/fix-unused-warning
Fix unused parameter warning
2021-12-13 09:27:29 -06:00
Richard Maw
38b9645bed fix: Windows Multicall support
The executable suffix is unconditionally stripped off the file path
so that the file name matches subcommands names
without having to add the EXE suffix on different platforms.
2021-12-12 22:08:25 +00:00
Richard Maw
e3d355fa85 feat: Make Multicall just strip dir from argv0 2021-12-12 22:08:25 +00:00
Ed Page
378e8d733d
Merge pull request #3150 from japert/improve-subcommand-deprecation-message
Improve `SubCommand` deprecation message.
2021-12-11 17:42:03 -06:00
Janis Peukert
1f51e8cb2f docs: Clarify deprecation message for SubCommand
Only `SubCommand` is deprecated, not `Subcommand`.
This new deprecation message mentions this ambiguity.

Resolves #3147.
2021-12-11 14:47:08 -08:00
rhysd
b498876cd8 fix: Fix unused parameter warning 2021-12-12 00:44:14 +09:00
rhysd
bc12ef168a feat: Include argument ID in UTF-8 assertion messages
so that users can understand which argument was going wrong.
2021-12-11 15:35:51 +09:00
Ed Page
756f825521 fix: Point to public method on ArgMatches panic
This will make it faster for someone to figure out what is going on
without dropping down to `RUST_BACKTRRACE=1` by giving them the arg
*and* telling them which function *they* called was involved.
2021-12-09 18:51:28 -06:00
Ed Page
264dc37e50 fix: Report if mixing subcommands and args
This is especially helpful for people transitioning off of `is_present`
being used for subcommands.

Fixes #3139
2021-12-09 18:49:51 -06:00
Ed Page
d38452c953 refactor: Clarify explicit display order wins
Now that we use options, we can rely on that, instead of sentinels, for
detecting a default and overriding only a default.

Noticed this as part of looking at #1807.
2021-12-09 16:24:49 -06:00
Ed Page
8a30b01bc1 refactor(yaml): Freeze FromStr 2021-12-09 09:36:00 -06:00
Ed Page
f16bdcc821 fix!: Limit Setting FromStrs to YAML
These exist pretty much just for YAML (#3087).  If anyone else is
building on these, it has a limited shelf-life anyways because of #2717.

BREAKING CHANGE: `FromStr` for settings requires the `yaml` feature.
2021-12-09 09:03:54 -06:00
Ed Page
9d7becca68 docs: Update deprecation messages
- Some still referenced the clapng issue number
- Some YAML ones were missed in the formatting clean up
- I never updated the usage ones with the formatting clean up
2021-12-09 06:47:37 -06:00
Colin Wahl
0b2a04c572 fix: Fix typo 2021-12-08 22:50:18 -08:00
Colin Wahl
f396b28419 chore: Pack exclusive setting into ArgSettings 2021-12-08 22:48:17 -08:00
Ed Page
d42cfee912 docs: Auto-tag feature flags
Fixes #3095
2021-12-08 20:37:53 -06:00
Ed Page
ffa5630de5 docs: Enable lib doc in more cases
Before, we limited it to the `doc` feature because of how extensive the
README was.  It has since scaled back, so we can be more selective with
what features enable it.
2021-12-08 20:37:50 -06:00
Ed Page
e98253dd4a fix: Rename 'doc' feature
This is prep for potentially other 'doc' changes
2021-12-08 20:10:47 -06:00
Ed Page
e5997c1001 docs: Clarify deprecations 2021-12-08 11:14:47 -06:00
Ed Page
76828fada8 docs: Guide people to missing_docs lint 2021-12-07 21:22:12 -06:00
Ed Page
e9b19d676b
Merge pull request #3078 from epage/fixes
Misc fixes from clapng fork review
2021-12-07 21:02:39 -06:00
Ed Page
7f54ecfd0a fix: Deprecation notice for UnifiedHelpMessage,
I missed this in my previous sweeps for re-adding-but-deprecating
Settings.
2021-12-07 18:27:32 -06:00
Ed Page
093de2b83b docs: Add back in logo 2021-12-07 17:45:57 -06:00
Ed Page
e3da325b5a docs: Link out to the crate_ macros 2021-12-07 17:45:57 -06:00
Ed Page
26bbe606d3 Revert "Revert "Revert "docs: Clarify corner caseses with default values"""
This reverts commit 98f696c0a6.

This was previously missed.  See #3076
2021-12-07 17:45:57 -06:00
Ed Page
c1033a3d7a refactor: Simplify Arg::new 2021-12-07 17:45:57 -06:00
Ed Page
4a5d52350e docs: Update old repo location 2021-12-07 08:14:41 -06:00
Ed Page
b2836c07a7 fix: Gracefully handle empty authors 2021-12-06 11:30:26 -06:00
Ed Page
c23f9230d1 chore: Remove stale boiletplate 2021-12-06 11:04:41 -06:00
Ed Page
8595357542 chore: Only error for warnings in CI
This makes it easier for developers to iterate, not having to stop to
write docs just to get things building.
2021-12-06 11:03:14 -06:00
Ed Page
b46abb7236 docs: Re-order items in docs
This contains two types of re-ordering:
- Internal, putting the focus of each file first.
- Public, re-arranging items and grouping impl blocks to try to better
  organize the documentation and find related items.

The main weakness of the docs work is in `Args`.  Its just a mess.  In
particular, we should probably link the simple casesm like `required` to
the advanced impl block.

Fixes #55
2021-12-04 19:18:28 -06:00
Pavan Kumar Sunkara
cc2dddba8e Add DisableColoredHelp setting to improve flexibility (clap-rs/clap#2956)
Until we have a modular help generator that can be configured and/or
authored by the users themselves as part of #2914, we will provide the
flexibility of turning off colored help messages but still wanting
colored error messages.

This flexibility was available before #2845 and @dbrgn immediately
noticed it and requested it back to which I agree. This was also
suggested by Josh in
[here](https://github.com/clap-rs/clap/issues/2806#issuecomment-933877438)
2021-12-04 12:00:46 -06:00
Ed Page
0cd16c34fc feat: App::debug_assert test helper
This will especially be important for users migrating from clap2 so they
can catch problems earlier in the process.
2021-12-03 14:12:03 -06:00
Ed Page
500def4904 fix(derive): Smooth out transition for structopt
Adding in a `StructOpt` derive with `structopt` attributes, with
deprecation notices.  Unofrtunately, not as many deprecation warnings as
I would like.  Apparently, you can't do them for a `use` of a derive?  I
also wanted to inject code that would trigger a deprecation notice for
attributes but that would require enough of a refactor that I didn't
consider it worth it.  We are at least providing a transition window
even if it means we'll have to remvoe it next major release without a
deprecation warning.
2021-12-02 20:18:33 -06:00
Ed Page
75d417851b docs: Clean up 3.0 changelog 2021-12-02 16:07:43 -06:00
Ed Page
3f9da04744 fix: Revert as much yaml policy to v2 as possible 2021-12-02 16:06:21 -06:00
Ed Page
0294fd0170 revert: Bring back ArgSettings::Global
This is a partial revert of cacc23473.  It appears that the deprecation
of `ArgSettings::Global` was never followed through on.
2021-12-02 16:06:21 -06:00
Ed Page
c93809271c fix: Deprecate, rather than obsolete, some App functions 2021-12-02 16:06:21 -06:00
Ed Page
c8254918d6 fix: Add back arg_enum 2021-12-02 16:06:21 -06:00
Ed Page
e065d1dd79 fix: Fix deprecated function name 2021-12-02 16:06:21 -06:00
Ed Page
d876f306eb fix: Add back in write_version 2021-12-02 16:06:21 -06:00
Ed Page
0d1f34b91d fix: Finish reverting clap_app 2021-12-02 10:45:10 -06:00
Ed Page
83abb24002 fix: Remove EmptyValues
The intention had been to that people setting this would now set
nothing.  Unfortunately, clap2 had `EmptyValues` as the default, so
people were more likely to unset it, making this not work out.
2021-12-02 09:59:41 -06:00
Ed Page
267de95bee fix: Change app_from_crate default separator
`":"` isn't ideal, so let's make it at least `"," `.

BREAKING CHANGE: Changed `app_from_crate!()` to use `", "` separator for
authors.
2021-11-30 14:56:17 -06:00
Ed Page
181eff5541 docs: Fix stale examples
These were broken in #17 and #38 when renaming `hidden` to `hide`.  These
weren't caught because we test with `--all-targets` which is mutually
exclusive with `--doc`.
2021-11-30 12:05:30 -06:00
Ed Page
ea73ec521b
Merge pull request #44 from epage/examples
docs: Prefer `global_setting`
2021-11-29 16:40:20 -06:00
Ed Page
30f5872a71 fix: Consistent help between Args and Subcommands
`App::subcommand_placeholder` encompassed
- `Arg::value_name`
- `Arg::help_heading`

Split it and renamed it to make it more consistent.
2021-11-29 16:17:02 -06:00
Ed Page
54228ef7d7 docs: Prefer global_setting
I've been finding I've been setting `AppSettings` without it which is
likely leading to bugs.  This tries to raise the visibility by using it
based on the setting being used and not whether the application needs
it.
2021-11-29 16:10:54 -06:00
Ed Page
b8c34c3b57 fix: Detect when AllowInvalidUtf8 is needed
Fixes #36
2021-11-29 15:37:44 -06:00
Ed Page
c5f5c49766 refactor(parser): Use modern '?' 2021-11-29 14:20:25 -06:00
Ed Page
8a1099f921 refactor(parser): More context when creating a MatchedArg 2021-11-29 14:01:08 -06:00
Ed Page
211d36efad refactor(parser): Be consistent on terms 2021-11-29 14:01:02 -06:00
Ed Page
44700506eb docs: Be consistent in builder args 2021-11-29 11:21:45 -06:00
Ed Page
62d7a3a928 fix: Be consistent on hide/hidden
- `PossibleValue::hidden` -> `PossibleValue::hide` (new in clap3, no
  breakin change)

Fixes #33
2021-11-29 10:58:00 -06:00
Ed Page
57e5fc2b07 fix: Rename to Arg::ignore_case like ArgSettings
Fixes #32
2021-11-29 10:34:42 -06:00
Ed Page
8fc12586bb fix: Make AppSettings::HidePossibleValues mirror ArgSettings
Fixes #31
2021-11-29 10:28:31 -06:00
Ed Page
eae3ffb599 docs: Emphasize Arg over ArgSettings 2021-11-29 09:54:04 -06:00
Ed Page
d1eec17d03 docs: Remove references to YAML 2021-11-24 16:09:56 -06:00
Ed Page
a2f0863a30 docs: Polish reference API 2021-11-24 16:09:53 -06:00
Ed Page
314a6a36bb fix: Rename HelpRequired to HelpExpected
This both distances itself from our 'require' terminology and aligns
itself with `Option::expect`, making it more likely for people to guess
the intended behavior.
2021-11-24 11:38:57 -06:00
Ed Page
5210744d3a
Merge pull request #26 from epage/hyphen
fix: Rename App's AllowLeadingHyphen to AllowHyphenValues
2021-11-24 11:38:26 -06:00
Ed Page
c15a0bf5b3 fix: Rename App's AllowLeadingHyphen to AllowHyphenValues
This aligns us with `Arg::allow_hyphen_values` in clap2.
2021-11-24 11:25:48 -06:00
Ed Page
4b72d3cc7f feat: Color debug output 2021-11-24 11:21:40 -06:00
Ed Page
463d75474e refactor(color): Track style, rather than details
This makes it easier for us to compose.  Before, we had to infer things
like "bold" based on the color.  Now we just say "error" and get all of
the formatting specific to that.
2021-11-24 11:21:40 -06:00
Ed Page
6a580d4de2 fix: Deprecate, rather than remove, AllowLeadingHyphen 2021-11-24 10:24:18 -06:00
Ed Page
d4173bd596 docs: Clean up deprecations 2021-11-23 10:32:05 -06:00
Ed Page
3c3a0b71d1 fix: Deprecate runtime usage parser
Fixes #8
2021-11-23 09:53:04 -06:00
Ed Page
4c4a2b86a0 refactor: Port over to arg! 2021-11-23 09:37:14 -06:00
Ed Page
263fe30568 feat: Usage parser macro
This is intended to replace the runtime usage parser and is not meant to
be a complete API in of itself, like `clap_app!`.  What is in scope is
everything that visually makes sense as in a usage string (see
[docopt](http://docopt.org/) for inspiration).  General setting of
attributes is out of scope.

This deviates from both `clap_app` and the runtime usage parser
- `clap_app` supported multiple values but has a bug because we made
  `Arg::value_name` non-appending, so we aren't supporting this yet
- We do not yet support optional flags that take a value
- In both, `...` is multiple occurrences and values while its only
  multiple occurrences for us
- We explicitly support optional values for flags
- Unlike `clap_app`, our name is optional
- Unlike runtime usage parser, our name syntax is simpler
- Unlike runtime usage parser, our name syntax does not allow modifiers

Its more limited than I would like.  Hopefully some people better with
macros can expand the feature set and turn more runtime errors into
compile-time errors.

This is to prepare for deprecating the runtime usage parser (#8).
2021-11-22 16:21:09 -06:00
Ed Page
136c8e229d fix: Arg::default has correct display order 2021-11-22 16:17:46 -06:00
Ed Page
fb917072f5 feat: name API 2021-11-22 16:17:46 -06:00
Ed Page
d159a3c2a4 docs: Clarify macro deprecation 2021-11-22 16:17:46 -06:00
Ed Page
19cd5ae9f0 docs: Update deprecation refrence 2021-11-22 16:17:46 -06:00
Ed Page
7604b1ed4a revert(usage): Go back to clap2 behavior 2021-11-22 16:17:46 -06:00
Ed Page
77b1adc950 Revert "fix(usage)!: Separate mutli-occ from multi-val syntax"
This reverts commit 53bd42a809.
2021-11-22 16:17:46 -06:00
Ed Page
7ac79da34a docs: Update clap_app docs 2021-11-22 16:17:46 -06:00
Ed Page
6ce9714e2b fix: Deprecate YAML API
Fixes #9
2021-11-22 16:17:46 -06:00
Ed Page
88fff13e71 Revert rename of from_yaml / from_usage
Since usage parser and yaml are on the way to being deprecated (#8, #9),
doing a rename also seems excessive, so rolling it back.

Past relevant PRs:
- clap-rs/clap#1157
- clap-rs/clap#1257
2021-11-22 16:17:46 -06:00
Marcin Puc
b95ced6fb3 Fix docs for Arg aliases (clap-rs/clap#3044) 2021-11-22 08:58:39 -06:00
Ed Page
7e899cd340 Revert "Deprecate Arg::help in favour of Arg::about"
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840

This is part of #16.  clap-rs/clap#1840 wasn't the right call but we
don't have time to make the decision now, so instead of having one
option and changing it in 4.0, this reverts back to clap2 behavior.
2021-11-18 12:25:49 -06:00
Ed Page
cd3837dccb
Merge pull request #13 from epage/examples
Fix problems found when testing examples
2021-11-17 21:19:29 -06:00
Ed Page
ff476660ce test: Compile example in README 2021-11-17 21:01:56 -06:00
Ed Page
9753f68a76 revert: Default value behaviour with conflicts and requirement validation
This feature is too immature at this stage in the release.   See
clap-rs/clap Issue 3020 when bringing this feature back.

This reverts commit 301c6f765a.
This reverts commit 43a4c90c86.
This reverts commit 4e29777b21.
This reverts commit 69957c4ddd.
This reverts commit bdb1d324a5.
This reverts commit b102da0cd2.
This reverts commit 72429be14e.
This reverts commit 0b7def675b.
This reverts commit b86aa631be.
This reverts commit 6b458c602d.
2021-11-17 15:45:50 -06:00
Ed Page
221c18bdec fix(error): Ensure value_of_t errors have trailing newline
Noticed this with `12_typed_values.rs`
2021-11-17 15:23:31 -06:00
Ed Page
dd974168fd docs: Fix typos 2021-11-17 15:21:58 -06:00
Ed Page
4479282b11 style: Address warnings 2021-11-17 14:23:32 -06:00
bors[bot]
ca3e14ca2d
Merge #3014
3014: fix(app): Propogate color  r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-13 10:43:42 +00:00
bors[bot]
98c1a75949
Merge #3016
3016: Revert "Automatically read license field from Cargo.toml" r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-12 16:16:35 +00:00
Ed Page
7a59dc3da4 Revert "Automatically read license field from Cargo.toml"
This reverts commit 6898fbde33.

PR #2144 added the `license` field but no consumer has been added since
the (like Issue #1768).  Since this is not ready yet, I am pulling it
from the 3.0 release.

So far, our main route for pulling a feature from the release has
been to put it behind a `unstable-*` feature flag and to create a
stablization tracking issue.  I chose to instead remove the feature
because a write-only field with no effect does not provide values for
people to use in as an early access and so doesn't outweight the cost of
the extra documentation noise and code noise it creates.  Additionally,
keeping an `unstable-` feature around when it has such an unknown path
(and time table) to stalbization feels like it violates YAGNI.  I'm
uncertain how much of this feature we can implement and not create a
legal trap for users because the crate's license is insufficient for the
final artifact's license.  I feel our stabliazation process sshould be
about iteration and collecting user feedback which this doesn't line up
with.

When someone is ready to tackle #1768, it will be easy to revert this
commit and pick up the work again.

Fixes #3001
2021-11-12 09:55:37 -06:00
Pavan Kumar Sunkara
301c6f765a Added and used ArgPredicate api 2021-11-11 22:33:30 +00:00
Pavan Kumar Sunkara
43a4c90c86 Remove is_default_value in favor of contains_explicit_value 2021-11-11 22:07:29 +00:00
Pavan Kumar Sunkara
4e29777b21 Added contains_explicit_val function instead of contains_val 2021-11-11 22:07:29 +00:00
Pavan Kumar Sunkara
69957c4ddd Revert "Revert "Fixes arg having required_unless on default values""
This reverts commit 6e85fb3ae0.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
bdb1d324a5 Revert "Revert "Fixes arg having required_if on default values""
This reverts commit 8818327b25.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
b102da0cd2 Revert "Revert "Fixes arg and group with default value having requires""
This reverts commit bd8c36cf04.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
72429be14e Revert "Revert "Fixes group conflicting if two args with default values""
This reverts commit 4e370bb093.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
0b7def675b Revert "Revert "Fixes arg conflicting with group whose arg has default value""
This reverts commit 706085d9c5.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
b86aa631be Revert "Revert "Fixes group conflicting with arg which has default value""
This reverts commit 736cb28dd0.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
6b458c602d Revert "Revert "Added ArgMatcher::is_default_value abstraction""
This reverts commit 5e76e6c568.
2021-11-11 21:33:50 +00:00
Pavan Kumar Sunkara
45f281b67e Revert "Revert "Revert "docs: Clarify corner caseses with default values"""
This reverts commit 98f696c0a6.
2021-11-11 21:33:50 +00:00
Ed Page
a2c3b14bb0 fix(app): Propogate color
In #2851, we moved color from an AppSetting to function (with some
tweaks in #2907).  When doing this, we documented `App::color` to be
equivalent of `App::global_settings(Color...)` but never actually
propagated it.

We are now propagating it.  A test is added to ensure that no matter
how we store the color choice, we continue to propagate it.  This
required exposing `App::get_color`.
2021-11-11 11:39:21 -06:00
Ed Page
ae67496473 feat(app): Expose App::get_color
This will be important for testing color support.  No idea how much
users will care.
2021-11-11 11:34:20 -06:00
Ed Page
839ad67b6b Revert "Add App::mut_args"
This reverts commit 6e4ac4cffc.
2021-11-05 09:29:38 -05:00
Ed Page
23b1502c00 Revert "Fix docs variable name"
This reverts commit 0dded91541.
2021-11-05 09:28:23 -05:00
Ed Page
4b0048666a fix: Allow unicode aware case insensitivity
In #2985, I noticed #2834 was incomplete, there were case-insensitive
comparisons we were doing without being unicode aware (when compile
options are set).

The downside is that each comparison will require a UTF-8 validation.
These seem to be in more of corners of the API, rather than in common
calls in common usages, so hopefully that isn't too much of a problem.
2021-11-04 12:23:02 -05:00
bors[bot]
879dd23963
Merge #2986
2986: Revert #2950 to make sure we get it properly in #2985 r=epage a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-11-03 18:51:19 +00:00
Pavan Kumar Sunkara
98f696c0a6 Revert "Revert "docs: Clarify corner caseses with default values""
This reverts commit 4edcda2b99.
2021-11-03 18:27:12 +00:00
Pavan Kumar Sunkara
5e76e6c568 Revert "Added ArgMatcher::is_default_value abstraction"
This reverts commit 261a2c00e8.
2021-11-03 18:26:15 +00:00
Pavan Kumar Sunkara
736cb28dd0 Revert "Fixes group conflicting with arg which has default value"
This reverts commit 8c76556ac4.
2021-11-03 18:25:53 +00:00
Pavan Kumar Sunkara
706085d9c5 Revert "Fixes arg conflicting with group whose arg has default value"
This reverts commit 64a2866b09.
2021-11-03 18:25:25 +00:00
Pavan Kumar Sunkara
4e370bb093 Revert "Fixes group conflicting if two args with default values"
This reverts commit 01869744c2.
2021-11-03 18:24:50 +00:00
Pavan Kumar Sunkara
bd8c36cf04 Revert "Fixes arg and group with default value having requires"
This reverts commit 130dcbfdd9.
2021-11-03 18:22:19 +00:00
Pavan Kumar Sunkara
8818327b25 Revert "Fixes arg having required_if on default values"
This reverts commit a88562c12b.
2021-11-03 18:20:39 +00:00
Pavan Kumar Sunkara
6e85fb3ae0 Revert "Fixes arg having required_unless on default values"
This reverts commit ac1de1fc78.
2021-11-03 18:18:54 +00:00
bors[bot]
3cc46a1c83
Merge #2984
2984: fix: Switch sub-commands from multi-val to multi-occur r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-03 16:59:25 +00:00
Ed Page
8212647bb3 fix: Switch sub-commands from multi-val to multi-occur
Similar to #2977, this changes positional argument `<subcmd>` in
`help <subcmd>` to be multiple occurrences, from being multiple values.

This is what identified the usage generation bug fixed in #2978 and was
isolated into the test case `positional_multiple_occurrences_is_dotted`.

This is part of #2692 where we re-evaluate the usage of multiple values
for positionals now that we accept multiple occurrences.
2021-11-02 20:55:43 -05:00
bors[bot]
ae48175207
Merge #2977
2977: fix(usage)!: Switch positionals... from multi-val to mulit-occur r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-03 01:47:44 +00:00
bors[bot]
9365f6a0af
Merge #2907
2907: fix: Ease clap2->3 transition for Settings r=kbknapp a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-11-03 00:41:14 +00:00
Ed Page
66341b3c11 fix: Always respect positional occurrences
When supporting multiple occurrences for positional arguments in #2804,
I added some tests to cover this but apparently simpler cases fail
despite those more complicated cases being tested.

This adds more multiple-occurrences tests for positional arguments,
fixes them, and in general equates multiple values with occurrences for
positional arguments as part of #2692.  There are a couple more points
for consideration for #2692 for us to decide on once this unblocks them
(usage special case in #2977 and how subcommand help should be handled).

I fully admit I have not fully quantified the impact of all of these
changes and am heavily relying on the quality of our tests to carry this
forward.
2021-11-01 14:14:04 -05:00
Ed Page
ade6028da1 fix: Loosen reflection lifetimes
Though we store a lot of values as `&'help str`, we return them as
`&'self str`, making it so they can not be used programmatically as part
of a `App::mut_arg` call.

This loosens the lifetimes so they can be used with `App::mut_arg`.
This also includes a test simulating the desired workflow described in #2966

I skipped `get_all_aliases`.  I ran into problems with lifetimes with
`all_subcommand_names`  and didn't quickly resolve it.  Rather than hold
this up, I punted on it for now.

We'll have to tighten these back up with #1041 but that will also enable
turning them into owned strings, so this will still be possible after
that issue is resolved, just the calls will be slightly different.
2021-11-01 16:28:43 -05:00
Ed Page
dd2c4c6346 fix(usage)!: Switch positionals... from multi-val to mulit-occur
I noticed this while investigating #2692.  Since we are making
multiple-occurrences a thing for positional arguments, this allows us to
remove a special case.

Another way to look at this is that we should make the default whatever
we do for dervies (#1772).  I'm going to propose we make the derive
always turn `Vec<i32>` into multiple occurences and not multiple values
(with users being able to change it through attributes), but that is an
in-work proposal and not decided yet.

BREAKING CHANGE: `Arg::from(...)` will now use `multiple_occurrences`
for a positional `...`, rather than `multiple_values`.
2021-11-01 12:15:00 -05:00
bors[bot]
96e7dfeb43
Merge #2969
2969: refactor: Allow partially used genned code r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-31 10:32:32 +00:00
Ed Page
53bd42a809 fix(usage)!: Separate mutli-occ from multi-val syntax
In looking at multiple occurrences and values for issues like #2692, I
noticed that `...` can mean both multiple values and multiple
occurrences, like before we split them.

Pros
- No syntax change with clap3

Cons
- All the reasons we split `multiple` into two

Uncertain
- I originally started this as part of another branch but I lost track
  if something depended on this.  I'll have to do more digging

BREAKING CHANGE: If `--opt [val]...` was meant for
- only multiple occurrences, see `[opt]... --opt [val]`
- both multiple occurrences and values, see `[opt]... --opt [val]...`
2021-10-30 12:56:49 -05:00
bors[bot]
dfa4690c96
Merge #2972 #2973
2972: refactor: Remove unused variable r=pksunkara a=epage



2973: test(usage): Make cases more consistent r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-30 18:05:11 +00:00
Ed Page
92df0ba263 test(usage): Make cases more consistent
Besides being more explicit / clear, this makes it easier to experiment
with tweaking the logic and keeping the test updates minimal, so the
change of behavior stands out more.
2021-10-30 12:11:49 -05:00
bors[bot]
0e674bcb48
Merge #2968 #2971
2968: test(derive): Provide better error info r=pksunkara a=epage



2971: Fix grammar in doc comment r=epage a=QuantumCoded



Co-authored-by: Ed Page <eopage@gmail.com>
Co-authored-by: Jeffrey <QuantumCoded@users.noreply.github.com>
2021-10-30 16:53:07 +00:00
Ed Page
7661f1f50d refactor: Remove unused variable 2021-10-30 11:46:39 -05:00
Jeffrey
d6c2ab4891
Fix grammar in doc comment
Added space after period in doc comment for `subcommand_name`
2021-10-30 10:37:14 -05:00
Ed Page
391980286e refactor: Allow partially used genned code
Wow, I'm having a hard time summarizing this for the summary.

When we code-gen Settings using `impl_settings`, we have no control over
whether one instance of a Settings will use some or all functions.  I
have a fix that removes the one `ArgSettings::unset`, causing warnings
for `ArgSettings` despite needing it for `AppSettings`.

So I'm making it less dependent on how each instantiation uses it.
2021-10-30 10:29:39 -05:00
Ed Page
ca29e4760c chore(error): Remove unused backtrace warning
Technically, this also fixes a bug with an extra newline when building
with `debug` but that is a pretty minor cosmetic issue.  It is unclear
if `backtrace` has a trailing newline or not, so I left that as-is.
2021-10-30 09:26:37 -05:00
bors[bot]
b42e2baf59
Merge #2967
2967: fix(derive): Support WaitOnError for derive-genned errors r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-30 14:20:27 +00:00
Ed Page
21cc39678b fix(derive): Support WaitOnError for derive-genned errors
Before, `Error::exit` didn't provide `WaitOnError`, requiring each call
site to duplicate half of `Error::exit`s behavior to get it.  This
hadn't been done for errors raised by derive-generated code.  Ideally,
these errors never happen but all the same, having this consistent would
be good.

This moves knowledge of `WaitOnError` to `Error` (including through
`Error::format`) so `Error::exit` can wait.  Now all of the callers to
`.exit` get a consistent experience without duplication.

While #2938 made a lot of `Error` fields optional for less churn-heavy
modifications, I made this new field required to minimize the risk of an
raise site forgetting to set it.
2021-10-30 09:08:11 -05:00
Johan Andersson
0dded91541
Fix docs variable name
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-30 12:55:46 +02:00
Johan Andersson
6e4ac4cffc Add App::mut_args 2021-10-30 12:26:15 +02:00
Ed Page
6126f998d1 fix(error): Never show unrequested color
If the user prints a raw error, it may include color even if the user
turned it off at runtime.  Now we'll be more conservative and never show
color for raw errors.

This is a follow up to #2943; apparently I had missed some cases.
2021-10-29 16:28:23 -05:00
Pavan Kumar Sunkara
92977060be
Allow r_unless_all to be used along with r_unless_any 2021-10-28 00:10:30 +01:00
bors[bot]
0d7a0a81c2
Merge #2950
2950: Fix default value behaviour with conflicts and requirement validation r=pksunkara a=pksunkara



Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-10-27 20:16:21 +00:00
Ed Page
4835c00419 fix: Ease transition for now-default settings
We prefer Settings to always be off by default, so when we change a
default, we have to rename.

This adds back in the now-default settings with deprecation messages to
help the user know how things now work.

Unfortunately, there is no way to notify the user that the default they
relied on has changed.  This also doesn't help us when the change in
behavior is more than just an inverting, like `InvalidUtf8` or when a
setting mapped to multiple bits.
2021-10-27 13:07:06 -05:00
Ed Page
99058014d8 fix: Allow using deprecated color AppSettings
This partiall reverts commit efeb02cd34,
bringing back the `AppSettins::Color*` and making them the backing store
for `App::color`, to help ease the transition from clap2->3.

Once we remove these deprecated settings, we might want to keep this
backing store to save on memory.

This is a part of #2617
2021-10-27 13:07:06 -05:00