Commit graph

4070 commits

Author SHA1 Message Date
Kevin K
bb26ed1c8b
imp: adds debug_asserts against generating meaningless flags
This commit adds several debug asserts that ensure the user has not
accidentally generated a version flag that has no information. The
exception to this case is when the user wants to generate a version
flag, but then handle the version display manually. I.e. one can still
generate a "meaningless" version flag, but use
`AppSettings::NoAutoVersion` which is allowed.
2021-10-09 11:12:50 -04:00
Kevin K
07aae5ac54
docs(AppSettings): documents NoAutoHelp and NoAutoVersion
Since these tie in closely with the new default behavior of not
auto-generating the `-V/--version` flags when no information has been provided they are now documented.
2021-10-09 11:12:50 -04:00
Kevin K
14c8850019
tests: fixes test to new default behavior
This commit corrects tests to not expect the `-V,--version` flag when no
version information has been provided.
2021-10-09 11:12:50 -04:00
Kevin K
0addd938a6
tests(Examples): fixes examples for no-auto generated version 2021-10-09 11:06:48 -04:00
Kevin K
7169c47fed
imp(version flag): no longer generates a version unconditionally
This commit changes the default behavior of clap to no longer generate a
`-V, --version` flag when no version information has been provided.

Version information can be provided via `App::version`,
`App::long_version`, or via `App::mut_arg("version", |_| ..)`. Using any
of the above is the only way to have clap auto-generate the version flag.

Technically, clap still generates a version flag, however it is removed
prior to parsing if the user has not provided any version information
via one of the mentioned methods.

Relates to [#2812](https://github.com/clap-rs/clap/issues/2812)
2021-10-09 11:06:48 -04:00
bors[bot]
5afa640e3b
Merge #2834
2834: fix: Allow unicode-aware case insensitivity with ArgValue r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-09 12:37:33 +00:00
Ed Page
56a6a7418e fix: Allow unicode-aware case insensitivity with ArgValue
This also opens us up to being more unicode aware in other places, like
our sorting of arguments in the help.

Fixes #2792
2021-10-09 07:21:45 -05:00
Ed Page
2bbe9123ee fix!: Generalize unicode feature
This flag was added in v3.  This will allow us to put more related
functionality behind it.

BREAKING CHANGE: `unicode_help` was renamed to `unicode`.
2021-10-09 06:27:28 -05:00
Ed Page
8546f0e348
Merge pull request #2828 from grant0417/master
feat(generate): Add fig autocomplete generator
2021-10-09 05:10:22 -05:00
bors[bot]
dd16fcccc3
Merge #2830
2830: fix(ci): Restore serialization of site deployment r=pksunkara a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-08 15:48:11 +00:00
Ed Page
598b87196a fix(ci): Restore serialization of site deployment
When removing `concurrency`, I overlooked this case where we want to
serialize deployments.

Queuing deployments also doesn't give us much.  I switched from using an
action for this to using built-in support.
2021-10-08 09:23:35 -05:00
grant0417
c3b8a96d65 Refactored fig generation code to crate 2021-10-07 20:54:14 -04:00
grant0417
8046f5074b Remove contib enum and expose contrib mod 2021-10-07 17:07:15 -04:00
bors[bot]
e3b23929b3
Merge #2823 #2824 #2827
2823: fix(derive): Subcommands not working within macro_rules r=epage a=epage



2824: docs(derive): Fix explanation on optional string list argument r=epage a=epage



2827: feat: Add backtraces to errors r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-07 18:49:59 +00:00
bors[bot]
6c2daef7a1
Merge #2821 #2822
2821: test(derive): Port structopt flatten coverage r=epage a=epage



2822: feat(derive): Add support for lower/upper in rename_all r=epage a=epage



Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-07 16:02:20 +00:00
Ed Page
e42487f6e8 fix(derive): Subcommands not working within macro_rules
This carries over a test case from
https://github.com/TeXitoi/structopt/pull/448, and re-fixes it according
to the changes we've made since we forked.  I also tried to  identify
other cases and quote them to avoid playing whack-a-mole with this.

This is a part of #2809
2021-10-07 10:05:30 -05:00
Ed Page
7761cf00d7 docs(derive): Fix explanation on optional string list argument
This is a port of https://github.com/TeXitoi/structopt/pull/450

This is a part of #2809
2021-10-07 10:02:34 -05:00
Ed Page
7b5a4c9c2d feat: Add backtraces to errors
This is gated behind the `debug` feature flag so only explicit debugging
cases pay the build time and runtime costs.

The builder API's stack traces are generally not too interesting.  Where
this really helps is with `clap_derive`.  We currently panic on
unexpected conditions which at least gives us a backtrace.  We'd like to
turn these into errors but to do so would lose those debuggin
backtraces, which is where this comes in.

This is a part of #2255
2021-10-07 10:02:34 -05:00
Ed Page
f681e46414 test(derive): Port structopt flatten coverage
https://github.com/TeXitoi/structopt/pull/414 was ported in
a95195874 but the test was less exhaustive.  This updates our test to
match structopt's latest version of the test.

This is a part of #2809
2021-10-07 10:02:34 -05:00
Ed Page
e10b5281d6 feat(derive): Add support for lower/upper in rename_all
Some programs do not use anything to separate word boundaries.

For example a struct may contain the field `build_dir` while the flag is
`--builddir`.

This is a port of https://github.com/TeXitoi/structopt/pull/412

This is part of #2809
2021-10-07 10:02:34 -05:00
Ed Page
00f7fe5472
Merge pull request #2802 from epage/ci
Speed up PR feedback
2021-10-07 10:02:07 -05:00
Ed Page
8eb4377534
Merge pull request #2819 from epage/consistent
refactor(derive): Always do app_methods last
2021-10-07 09:04:42 -05:00
Ed Page
63275d3f13 Speed up PR feedback
This drops us down to just a handlful of jobs, allowing us full
parallelism (github caps max parallel jobs).  This is dependent on us
using bors to run the "ci" before merging into master.

There is a balance in what to run.  We should consider what is most
likely to break for the widest variety of PRs.  Contributors that expect
an uncovered case to fail can always specify `@bors try`

Motivation
- Mac is similar enough to Linux, we only need to run one of them and
  Linux has more parallel runners on Github.
- Since we deal with `OsStr`, test Windows because its different than
  the others.
- People are most likely to make changes on `stable` and break support
  for MSRV, so we should verify that
- Still test on `stable` to not block feedback if we run into problems
  with dependencies and our MSRV run.
- On the other hand, beta and nightly are less likely to break on an
  individual PR
- Remove benchmarks because most changes are not performance sensitive
  and we aren't looking at the results enough to justify a 30 minute run.

Fixes #2801
2021-10-07 09:02:28 -05:00
grant0417
b0edeb9be0 Move fig to contrib 2021-10-06 21:17:34 -04:00
Ed Page
74799ea916 Revert structopt #325
https://github.com/TeXitoi/structopt/pull/325 special cased `version`
because a default method would be added if the user did nothing, which
caused problems when nesting subcommands.  We no longer apply that
default method and the highest item in the chain always has precedence,
so this can be simplified / clarified.
2021-10-06 19:20:15 -05:00
Ed Page
412071a134 refactor: Be consistent in adding methods last
This will unblock us from removing the `version` hack because we'll
always get the right precedence.

Later we can explore ways of moving the app methods to being done first.
The big problem is with `#[clap(subcommand)]` because we need to call
those app methods on the subcommands `App` *and* override them with app
methods on the variant, requiring the app methods to be last to get
precedence.
2021-10-06 19:19:31 -05:00
Ed Page
29a6a854f1 fix(ci): Don't have PRs canceling each others jobs
Using `head_ref`, we are making it so PRs are all in the same group.
When a new PR comes in (not just an update), it then cancels all other
PRs.  Switching to `ref` makes it so each PR is in its own concurrency
group.
2021-10-06 19:16:55 -05:00
Ed Page
6594e28776
Merge pull request #2826 from epage/skip
feat(derive): Add skip attribute support for enum variants
2021-10-06 19:16:42 -05:00
Ed Page
64e9ecf79b
Merge pull request #2825 from epage/map
fix(derive): Fix the problem where the build fails due to the ambigous type of `map`
2021-10-06 19:16:27 -05:00
grant0417
f3611ad6b9 feat(generate): Add fig autocomplete generator 2021-10-06 19:42:42 -04:00
Ed Page
16023cf157 feat(derive): Add skip attribute support for enum variants
> Resolves #493

This is a port of https://github.com/TeXitoi/structopt/pull/494

This is part of #2809
2021-10-06 13:52:02 -05:00
Ed Page
51c723a84f fix(derive): Fix the problem where the build fails due to the ambiguous type of map
> This PR closes #490. Please refer to #490 for the detail of the problem. Let me know if you want to make `convert_type` a function.

This is a port of https://github.com/TeXitoi/structopt/pull/491

This is part of #2809
2021-10-06 13:22:56 -05:00
Ed Page
5512c90380
Merge pull request #2818 from epage/docs-panic
docs: Point people to common panic practices
2021-10-06 08:55:47 -05:00
Ed Page
e62a92f260
Merge pull request #2810 from epage/license
docs: Ensure all crates have license files
2021-10-06 08:55:25 -05:00
Ed Page
6f95650a91
Merge pull request #2805 from epage/validate_default
fix(derive): Type check `default_value_t`
2021-10-06 08:54:59 -05:00
Ed Page
6fd3e0b834
Merge pull request #2820 from epage/option
fix(derive): Support SubcommandsNegateReqs
2021-10-05 19:10:01 -05:00
Ed Page
a77e12e030 docs: Point people to common panic practices 2021-10-05 18:35:46 -05:00
Ed Page
9afa08ff50 fix(derive): Support SubcommandsNegateReqs
Before there was no way to make `SubcommandsNegateReqs` with
`clap_derive` because it required a required field with a sentinel value
for when the required part was negated.  We blocked that.

This turned out simpler than I expected.

This came out of the discussion for #2255 but that issue is more
specifically about the panic, so not closing it.
2021-10-05 16:02:02 -05:00
Ed Page
6c6b97daa8 docs: Ensure all crates have license files
In #2270, its brought up to solve this at the `cargo workspace publish`
level.  However, copying the files is a 5s fix without any design work,
it doesn't seem like support within an external tool should block us
from getting this fix into users hands.  Once `cargo workspace publish`
supports this and if we are still using it, we can re-evaluate.

Fixes #2270
2021-10-04 14:45:31 -05:00
Ed Page
62eff1f8d3
Merge pull request #2804 from epage/multiple
fix(parser): Allow multiple_occurrecnes with positional args
2021-10-04 13:57:33 -05:00
Ed Page
d0b22b53ff fix(derive): Type check default_value_t
Fixes #2064
2021-10-04 13:02:47 -05:00
Ed Page
8e780e364d fix(parser): Allow multiple_occurrecnes with positional args
This unblocks
- Defining repeated tuples in positional arguments
- Potentially using this in #1772

Fixes #2784
2021-10-04 12:09:54 -05:00
patrick-gu
edd0124af0
Fix disabling the default help and version subcommands/flags (#2796)
* Check for `DisableHelpFlag` along with `NoAutoHelp`

Also applies for `DisableHelpSubcommand` and `DisableVersionFlag` with `NoAutoVersion`

* Add tests for overriding help and version, and disabling version.

These override by disabling the default and adding a new one.

* Don't use `default_missing_value` for `override_version_using_short`

* Check errors by the API.

This changes the `disabled_version_long` and `disabled_version_short` tests.

This is opposed to comparing the stderr output.
2021-10-04 15:01:09 +01:00
Ed Page
236cf584cf
Merge pull request #2800 from ModProg/ArgValue-derive
Rename `ArgEnum::arg_value` to `to_arg_value`
2021-10-01 10:27:00 -05:00
ModProg
08e8c53862 refactor(ArgEnum): replace unwrap with except, arg_value -> to_arg_value 2021-10-01 16:14:10 +02:00
Ed Page
3b2e3ffddf
Merge pull request #2762 from ModProg/ArgValue-derive
ArgValue derive
2021-10-01 08:43:40 -05:00
ModProg
47ff3ed945 documentation for ArgValue 2021-09-29 20:55:47 +02:00
ModProg
d53778ed5d fix ui 2021-09-29 19:31:05 +02:00
ModProg
15fcf814c2 fix dummies 2021-09-29 19:05:16 +02:00
ModProg
480035ac9c ArgEnum: Slice instead of array, from_str in ArgEnum implemented 2021-09-29 18:33:43 +02:00