Paul Seyfert
25e337adb1
[clap_generate] [zsh] sort out multiple occurrence vs multiple_value.
2021-10-12 10:48:37 +01:00
bors[bot]
6d046c7aac
Merge #2848
...
2848: fix: Deprecate Macro API r=pksunkara a=epage
Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-12 07:36:50 +00:00
bors[bot]
a67aea232d
Merge #2852
...
2852: fix(help): Show [OPTIONS] with help_heading r=pksunkara a=epage
Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-12 00:55:16 +00:00
Ed Page
350ab9daf7
fix(help): Show [OPTIONS] with help_heading
...
This was changed in #1989 without an explanation:
- In the help template, there isn't a way to expose with help_headings,
so show all.
- In usage, we don't know whether the user wants to see `[FLAGS]` /
`[OPTIONS]` or not, so let's default to showing them.
2021-10-11 19:13:53 -05:00
Richard Maw
971b6b683e
fixup! Move explanatory text from examples to docstring
2021-10-11 22:08:51 +01:00
Ed Page
0a53fafddf
fix: Deprecate Macro API
...
Fixes #2835
2021-10-11 15:06:38 -05:00
Richard Maw
f14db03eec
Add Multicall setting
...
If the AppSettings::Multicall setting is given
then argv0 is parsed as the first subcommand argument
or parsed as normal with any other name.
2021-10-11 20:00:24 +01:00
Ed Page
35d53d9dcf
feat(generate): 'impl ArgEnum for Shell'
...
These keeps `FromStr` for ease of use with `value_of_t`.
This includes adding test to make sure everything works as expected.
2021-10-11 10:44:48 -05:00
bors[bot]
562e64c723
Merge #2845
...
2845: fix(help)!: Consoldiate color settings r=pksunkara a=epage
Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-11 14:17:10 +00:00
Ed Page
6dd9d467ce
fix(help)!: Consoldiate color settings
...
A lot of users expected `color` feature flag and `ColorAuto` etc to
control all colors. Having this extra flag around is easy to miss and
adds to our overall settings bloat, making it harder to find settings
people want.
This completely removes it, rather than make it deprecated like
functions in #2617 , because there is extra work to mark things
deprecated as Settings and we should decide on our strategy first before
investing time in addressing that issue.
Fixes #2806
2021-10-11 09:01:13 -05:00
Waleed Khan
e73ec0887d
add App::get_long_about
2021-10-10 17:17:55 -07:00
Ed Page
d840d5650e
fix(derive)!: Rename Clap
to Parser
.
...
Before #2005 , `Clap` was a special trait that derived all clap traits it
detected were relevant (including an enum getting both `ArgEnum`,
`Clap`, and `Subcommand`). Now, we have elevated `Clap`, `Args`,
`Subcommand`, and `ArgEnum` to be user facing but the name `Clap` isn't
very descriptive.
This also helps further clarify the relationships so a crate providing
an item to be `#[clap(flatten)]` or `#[clap(subcommand)]` is more likely
to choose the needed trait to derive.
Also, my proposed fix fo #2785 includes making `App` attributes almost
exclusively for `Clap`. Clarifying the names/roles will help
communicate this.
For prior discussion, see #2583
2021-10-09 20:12:03 -05:00
bors[bot]
e8ec11e57f
Merge #2837
...
2837: fix: Gate App::replace r=pksunkara a=epage
Co-authored-by: Ed Page <eopage@gmail.com>
2021-10-09 16:27:41 +00:00
Ed Page
dfbeb71077
fix: Gate App::replace
...
We are concerned about the level of polish of this feature and are
unsure enough about its future, we've decided to gate it to unblock the
v3 release.
2021-10-09 10:49:10 -05:00
Kevin K
7b45695878
breaking(DisableVersionForSubcommands): removed
...
This commit removes `AppSettings::DisableVersionForSubcommand` as it's
now a moot setting with clap's default functionality of not building a
version flag unless there actually exists version information.
`clap_up` must still be changed to remove this variant instead of the
current configuration to simply rename the variant.
2021-10-09 11:12:50 -04:00
Kevin K
9fbe5841a7
chore: clippy lint fixes
2021-10-09 11:12:50 -04:00
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
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
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
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
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
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
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
480035ac9c
ArgEnum: Slice instead of array, from_str in ArgEnum implemented
2021-09-29 18:33:43 +02:00
Pavan Kumar Sunkara
5940bb2360
Merge pull request #2794 from ldm0/simplify
...
Less format & branch
2021-09-28 22:21:09 +01:00
ModProg
ac1a9d6d13
address epage's remarks
2021-09-27 22:06:17 +02:00
liudingming
3206db99af
less format macro, less branches.
2021-09-27 23:34:13 +08:00
ModProg
76f7211d8b
small changes
2021-09-27 01:29:10 +02:00
ModProg
f002cdcc99
move alias implementation to ArgValue for derive
2021-09-27 01:18:47 +02:00
ModProg
d3f0534939
add hidden aliases to ArgValue
2021-09-26 22:46:23 +02:00
liudingming
7ba46400e4
Resolve a todo
2021-09-27 02:03:28 +08:00
Roland Fredenhagen
88d7d02555
Working Implementation
2021-09-26 16:32:46 +02:00
ModProg
b589a6ce06
feat(derive:arg_enum): use ArgValue in ArgEnum trait
2021-09-26 16:32:46 +02:00
Pavan Kumar Sunkara
699a3f76d6
Implement BitOr for settings
2021-09-23 14:57:10 +05:30
Roland Fredenhagen
5580e8c465
ArgValue builder ( #2758 )
...
* feat(arg_value): ArgValue can be used for possible_values
Through the ArgValue it is possible:
* `hide` possible_values from showing in completion, help and validation
* add `about` to possible_values in completion
* Resolved a few change-requests by epage
* make clippy happy
* add ArgValue::get_visible_value
* remove verbose destructering
* rename ArgValue::get_hidden to ArgValue::is_hidden
* add test for help output of hidden ArgValues
* Documentation for ArgValue
There is an issue that required to implement From<&ArgValue> for
ArgValue. We should probably find a solution without that.
* fix requested changes by epage
* fix formatting
* add deref in possible_values call to remove From<&&str>
* make clippy happy
* use copied() instad of map(|v|*v)
* Finishing up for merge, hopefully
* changes requested by pksunkara
2021-09-19 10:29:09 +00:00
patrick-gu
90dde89ec4
Apply value_delimiter
to default values
2021-09-18 15:15:25 -07:00
Ed Page
b3847b76c4
refactor: Remove vec_map dependency
...
Doesn't look like this dependency is buying us anything at this point,
so removing it.
2021-09-17 15:14:49 -05:00
Pavan Kumar Sunkara
76859b16bb
Merge pull request #2773 from tangmi/fix-large-display-order
...
Add test for very large display_order values and a possible fix
2021-09-17 19:39:37 +01:00
Mustafa Guler
50b9e65d39
Fix bug with duplicate error messages
...
This addresses a bug that causes duplicate flags reported in user-facing
error messages when two flags require one-another but also are required
under other conditions. The fix involves removing duplicates in unrolled
requirements, which addresses the user-facing aspect of this bug.
2021-09-17 10:47:06 -04:00
Michael Tang
cc592ed800
Add test for very large display_order values and a possible fix.
...
Fixes #2772
2021-09-16 19:11:30 -07:00
patrick-gu
044f9c5669
Don't suggest help
or --help
when not applicable ( #2749 )
...
* Don't suggest `help` or `--help` when not applicable
* Apply suggestions from code review
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
* Update test usage to match intended
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-09-04 20:10:24 +00:00
dylni
6311c894cc
Fix compile errors
2021-08-29 10:24:56 -04:00
dylni
a50591b16b
Fix warnings
2021-08-29 10:10:26 -04:00
dylni
dc65513966
Replace ArgStr
with os_str_bytes::RawOsStr
2021-08-29 10:00:30 -04:00
liudingming
898894cf35
Make clap::Error
Send
and Sync
again
2021-08-29 17:21:08 +08:00
liudingming
f200828045
Add regression test
2021-08-29 17:21:08 +08:00
Pavan Kumar Sunkara
f085fa64f4
Merge pull request #2722 from epage/group
...
fix(yaml): Don't panic on multiple groups
2021-08-19 07:40:41 +01:00
Ed Page
bd25b5f615
fix(yaml): Don't panic on multiple groups
...
Because we gradually build the `ArgGroup` as we parse the YAML, we don't
use `ArgGroup::new`. Clap3 introduced an internal `id` in addition to
the public `name` and it appears that this custom initialization code
was not updated.
This shows the problem with publically exposing `impl Default`.
Choices:
- Remove `impl Default`
- Always valid
- Requires spreading invariants
- Callers can't implement code the same way we do
- Add `ArgGroup::name`
- Can be constructed in an invalid state
- Centralizes invariants
- A caller could implement code like the yaml logic
I decided to go with `ArgGroup::name`.
Fixes #2719
2021-08-18 15:16:44 -05:00
Ed Page
aeaf01e3e7
fix: Provide path to avoid UTF-8 panics
...
Before, validating UTF-8 was all-or-nothing and would cause a `panic` if
someone used the right API with non-UTF-8 input.
Now, all arguments are validated for UTF-8, unless opted-out. This
ensures a non-panicing path forward at the cost of people using the
builder API that previously did `value_of_os` need to now set this flag.
Fixes #751
2021-08-18 14:15:18 -05:00
Ed Page
329fe4a24b
fix: Swallow broken pipes
...
Previously, we paniced. This is one less reason people have to call
lower level `get_matches` to get the commonly expected behavior, making
it more likely for the Rust community to "do the right thing"
Fixes #2659
2021-08-18 10:16:57 -05:00
Donough Liu
0394ae6102
Fix handling of number_of_values
when displaying arg ( #2701 )
...
* Remove dead logic
* Outline common logic
* Fix issue 1571
2021-08-17 09:17:18 +00:00
Pavan Kumar Sunkara
9d5cf64d6a
Merge pull request #2704 from jrheard/patch-1
...
fix typo
2021-08-16 10:45:33 +01:00
JR Heard
465d495b6d
fix typo
2021-08-15 20:02:18 -07:00
Pavan Kumar Sunkara
9dd75987df
Remove TakesValue restriction for HideEnv*
2021-08-15 19:40:24 +01:00
Pavan Kumar Sunkara
52be134949
Release 3.0.0-beta.4
...
clap@3.0.0-beta.4
clap_derive@3.0.0-beta.4
clap_generate@3.0.0-beta.4
Generated by cargo-workspaces
2021-08-14 23:40:49 +01:00
Pavan Kumar Sunkara
73b28fb104
Release 3.0.0-beta.3
...
clap@3.0.0-beta.3
clap_derive@3.0.0-beta.3
clap_generate@3.0.0-beta.3
Generated by cargo-workspaces
2021-08-14 23:01:13 +01:00
Pavan Kumar Sunkara
a9b86ecefc
Update changelog
2021-08-14 22:46:49 +01:00
TheDaemoness
f411a65d82
Fix invalid_value returning an Error with no info
2021-08-14 11:28:51 -07:00
Pavan Kumar Sunkara
203613d5e3
Merge pull request #2696 from ldm0/override
...
Make `overrides_with` working when `MultipleValues` is enabled.
2021-08-14 10:41:40 +01:00
liudingming
a85857dfb0
Make overrides_with working when MultipleValues
is enabled.
2021-08-14 16:34:26 +08:00
Pavan Kumar Sunkara
441ff68c2d
Merge pull request #2694 from clap-rs/env-feature
...
Add env feature gate
2021-08-14 03:11:21 +01:00
Pavan Kumar Sunkara
c7985fb73e
Add env feature gate
2021-08-14 01:55:05 +01:00
Pavan Kumar Sunkara
61eb921f63
Fix value_names & num_vals interaction
2021-08-14 01:08:44 +01:00
Ed Page
2eb22e2b36
fix!: value_name/value_names should not append
...
Instead they should behave like `default_value`/`default_values`.
In implementingt this, I didn't see any reason to be using a `VecMap`.
In fact, this helped simplify the code / make intent clearer.
With this, we are also able to simplify the derive macro work from #2633 .
Fixes #2634
BREAKING CHANGE: `value_name`/`value_names` always overwrite, rather
than append. We expect the impact to be minimal.
2021-08-13 15:37:03 -05:00
Pavan Kumar Sunkara
24bfd2b92c
Fix test errors
2021-08-13 20:58:38 +01:00
Pavan Kumar Sunkara
d64ced0311
Merge pull request #2686 from ldm0/delimiter
...
Make `value_delimiter` accept `char` rather than `String`
2021-08-13 20:53:21 +01:00
liudingming
a60836d96a
Make value_delimiter
accept char rather than String
2021-08-14 02:54:56 +08:00
liudingming
a8060d305b
Tweaks ArgsNegateSubcommands
's doc
2021-08-14 02:30:27 +08:00
Pavan Kumar Sunkara
476dd190b7
Merge pull request #2682 from clap-rs/checker
...
Set TakesValue to true for positional args when building
2021-08-12 22:46:15 +01:00
Pavan Kumar Sunkara
8f2ba607aa
Merge pull request #2534 from stevenengler/hide-heading
...
Hide help heading when all args are hidden
2021-08-12 21:32:07 +01:00
Pavan Kumar Sunkara
b4a662b6c9
Set TakesValue to true for positional args when building
2021-08-12 21:27:42 +01:00
Steven Engler
1bd63feffe
Hide help heading when all args are hidden
2021-08-12 00:51:58 +01:00
Pavan Kumar Sunkara
6ae15a79b6
Remove settings that are inherently global
2021-08-11 22:41:25 +01:00
rami3l
5a965caf1e
feat(parser): accept non-false
literals with env vars as true
, take 2
2021-08-10 19:13:43 +02:00
rami3l
5f781c72a5
feat(parser): accept non-false
literals with env vars as true
2021-08-10 12:21:12 +02:00
rami3l
d32b6bf764
fix(test): fix doc test
2021-08-10 12:21:12 +02:00
rami3l
f2f9b665ed
feat(parser): accept boolean literal with env vars, take 1
2021-08-10 12:21:02 +02:00
liudingming
696f93c4f5
Fix some work on ArgStr
2021-08-09 04:26:01 +08:00
liudingming
5f70e38c2a
Optimize ArgStr
2021-08-09 02:22:31 +08:00
liudingming
216aab2479
Remove TrailingValues from app settings
2021-08-08 03:41:23 +08:00
liudingming
963aa1977d
Remove ValidArgFound from app settings
2021-08-08 03:41:23 +08:00
liudingming
e851a82080
Move pos_counter before parsing flags.
...
Then checking if AllowHyphenValues is set when parsing flag is possible.
2021-08-08 03:38:41 +08:00
liudingming
b88d933d96
Extract erroring from parsing.
...
Rename needs_valueof to parse_result
Use ParseResult more
Less predicting, more fallback
Remove non-sense ParsingResult::NotFound
Merge FlagSubCommand and FlagSubCommandShort
Merge NoMatchingLongArg and NoMatchingShortArg
Better documentation for pos_counter bumping
Denoise of pos_counter
Split ParseState from ParseResult
Remove ParseResult::Flag
small cleanup
2021-08-08 03:38:40 +08:00
liudingming
82d25401a0
Move logic out
2021-08-08 03:34:10 +08:00
liudingming
ca8623c774
Remove duplicate empty value checker
2021-08-08 03:34:10 +08:00
liudingming
d2fec9128f
fmt::write -> push_str
2021-08-08 00:25:51 +08:00
rami3l
adc34a2680
fix(style): eliminate several clippy
warnings
2021-08-02 22:31:59 +02:00
Pavan Kumar Sunkara
4bec66dd03
Merge pull request #2619 from rami3l/flag-literal
...
fix(parser): Ban long flags with literals
2021-08-01 12:31:29 +01:00
rami3l
7f8f5ccc9a
Revert "fix(style): fix code format warning"
...
This reverts commit a4a4d4c307
.
2021-08-01 11:41:29 +02:00
Abyss
faa25f9e67
Make colorizer respect ColorChoice::Always
2021-07-31 18:12:54 -04:00
liudingming
ab119b342a
Fix value_of returns None when the first value group is empty
2021-08-01 03:56:23 +08:00
patrick-gu
88dec14775
Fix order of arguments in help message with AllowMissingPositional ( #2648 )
...
* Fix small formatting error
I accidentally introduced this in #2642
* Fix order of arguments in help message with AllowMissingPositional
2021-07-31 07:39:23 +01:00
Pavan Kumar Sunkara
ff95eb2f5b
Merge pull request #2647 from clap-rs/msrv
...
Bump msrv to 1.54.0
2021-07-31 05:45:02 +01:00
Pavan Kumar Sunkara
619f4c153c
Fix format
2021-07-30 23:01:05 +01:00
Pavan Kumar Sunkara
6994be4f15
Remove doc feature
2021-07-30 22:49:11 +01:00
rami3l
a4a4d4c307
fix(style): fix code format warning
2021-07-30 22:33:56 +02:00
rami3l
29e3dc2c47
fix(parser): run check_for_help_and_version_str
only if no literal is found with flag
2021-07-30 22:33:56 +02:00
rami3l
87479dfb8c
fix: ban all uses of literals with flags
2021-07-30 22:33:56 +02:00
rami3l
2d2db652ef
fix: fix #1649 , take 1
2021-07-30 22:33:56 +02:00
Ed Page
241d183b9c
Bump MSRV to 1.54.0
...
- This makes it so `doc` compiles on stable
Fixes #2618
2021-07-30 10:19:21 +01:00
liudingming
a419f25fdb
Fix issue, add tests
2021-07-30 15:39:34 +08:00
liudingming
3791f7e5ad
Fix long_arg
2021-07-30 15:39:34 +08:00
liudingming
5ab16f7199
Improve parse_long_arg
2021-07-30 15:39:34 +08:00
liudingming
e8838e1794
fix clippy
2021-07-30 15:39:34 +08:00
liudingming
9509372f12
Improve parse_opt
2021-07-30 15:39:34 +08:00
Pavan Kumar Sunkara
6ea223bc6e
Merge pull request #2644 from ldm0/clippy
...
Fix clippy
2021-07-30 08:38:34 +01:00
liudingming
44b7eee404
Fix clippy
2021-07-30 13:36:38 +08:00
patrick-gu
a4dc72ed19
Replace "Prints" with "Print" for default help and version commands
2021-07-29 20:23:25 -07:00
Ed Page
6a70c744e0
fix(derive): Allow partial update of flattened Subcommand arguments
...
When using `#[clap(flatten)]` inside of a `Subcommand`, we would do a
`from` instead of an `update`.
The challenge is knowing when we are
going into a flattened subcommand vs changing the variant. To resolve
this, I added a `Subcommand:has_subcommand(name)` trait method that we
generate, so we can ask.
2021-07-27 12:14:53 -05:00
Pavan Kumar Sunkara
5fbd764b06
Merge pull request #2622 from patrick-gu/master
...
Refactor creation of `App` and `Arg` from YAML
2021-07-27 10:31:55 +01:00
Ed Page
d643fb3c32
feat(derive): Make it possible to use ArgEnum with default_value
...
This doesn't solve the problem end-to-end but at least makes it possible
to solve by the user and improve in the future.
2021-07-26 10:33:14 -05:00
patrick-gu
9b64ac2b45
Refactor creation of App
and Arg
from YAML
...
Improved the `impl`s of `From` for `&'help Yaml` to use expects with useful messages instead of unwraps. Also made changes to avoid potentially fetching redundant data from YAML hashes and unwrapping the same data multiple times. Finally, there are tests to ensure the panics are correct.
2021-07-25 15:24:43 -07:00
Pavan Kumar Sunkara
79e3b37ecc
Merge pull request #2604 from epage/exit
...
fix(exit): Be consistent in exit code
2021-07-25 14:32:47 +01:00
Pavan Kumar Sunkara
27311139c2
Merge pull request #2610 from ldm0/value_name
...
Print `value_name` `number_of_values` times with single value_name
2021-07-25 14:23:21 +01:00
liudingming
62fa1e7454
Print value_name
number_of_values
times with single value_name
2021-07-21 03:38:58 +08:00
liudingming
6094520541
Don't show default_val in smart usage
2021-07-21 02:50:41 +08:00
Ed Page
6e24c849fb
fix(exit): Be consistent in exit code
...
PR #1637 switched clap to report `64` on errors and then #1653 switch it
to `2`, but both missed a case. This also documents the reason why inline
since I had to go and dig through the history to re-discover the
motivation.
2021-07-19 11:21:01 -05:00
hosseind88
cc2e07ea61
Remove a redundant word in AppSettings::NoBinaryName enum explanation
2021-07-19 17:56:57 +04:30
Ed Page
7f08773a5a
fix(derive)!: Compile-error on nested subcommands
...
Before, partial command lines would panic at runtime. Now it'll be a
compile error
For example:
```
pub enum Opt {
Daemon(DaemonCommand),
}
pub enum DaemonCommand {
Start,
Stop,
}
```
Gives:
```
error[E0277]: the trait bound `DaemonCommand: clap::Args` is not satisfied
--> clap_derive/tests/subcommands.rs:297:16
|
297 | Daemon(DaemonCommand),
| ^^^^^^^^^^^^^ the trait `clap::Args` is not implemented for `DaemonCommand`
|
= note: required by `augment_args`
```
To nest this, you currently need `enum -> struct -> enum`. A later
change will make it so you can use the `subcommand` attribute within
enums to cover this case.
This is a part of #2005
2021-07-15 11:45:13 -05:00
Pavan Kumar Sunkara
894be6799c
Merge pull request #2585 from epage/argenum
...
fix(derive): `Clap` should not derive `ArgEnum`
2021-07-14 18:01:31 +01:00
Ed Page
6cc76e7237
fix(derive): Clap
should not derive ArgEnum
...
While having convinience derives can be helpful, deriving traits that
are not used in similar situations (`Clap` and `ArgEnum`) can make
things harder
- From a user, derives are opaque and create uncertainty on how to use
the API if not kept crystal clear (deriving a name gives you the trait
by that name)
- This makes documentation harder to write and read
- You can use types in unintended places, which is made worse for crate
APIs because changing this breaks compatibility.
Fixes #2584
2021-07-14 10:50:26 -05:00
Pavan Kumar Sunkara
af6f7af368
Merge pull request #2577 from tshepang/fix-links
...
fix remaining intra-doc links
2021-07-13 00:43:28 +01:00
Ed Page
3be79b9e1b
docs(derive): Update trait doc-comments ( #2579 )
...
* docs(derive): Update trait doc-comments
* Apply suggestions from code review
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-07-12 21:43:03 +01:00
codedust
15d49064c3
Fix grammar in require_delimiter
fn docs
2021-07-11 12:19:54 +02:00
Tshepang Lekhonkhobe
b4eddf158d
fix remaining intra-doc links
2021-07-10 21:00:34 +02:00
Tshepang Lekhonkhobe
f5758034f0
fix a bunch of intra-doc links
2021-07-03 23:59:46 +02:00
anatawa12
89d1519f69
Show summary in subcommands list ( #2558 )
...
* Show short about in SUBCOMMANDS list
* add tests
* move test
* cargo fmt
2021-06-20 16:28:50 +01:00
Ethan Budd
6a48698fcd
Add a new arg option for the max_occurrences ( #2543 )
...
* add a new arg option for the max_occurrences
* check ErrorKind in tests
* Updated grammer in doc comments
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
* assert is_err() before unwraping
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-06-17 19:54:24 +01:00
Pavan Kumar Sunkara
373ded784c
Fix clippy lint
2021-06-17 19:19:56 +01:00
Rémi Lauzier
c4f534228b
Fix some nightly clippy warnings
2021-06-16 23:25:13 -04:00
Pavan Kumar Sunkara
947523f7f5
Merge pull request #2480 from kolloch/feature/partial-parsing
...
setting: IgnoreErrors - Allow parsing despite missing option values
2021-06-16 09:09:52 +01:00
Pavan Kumar Sunkara
e5e20b389e
Forbid multiple_occurrences for positional args
2021-06-16 08:27:04 +01:00
Pavan Kumar Sunkara
3f94d17c71
Removed Arg::multiple
2021-06-16 07:17:11 +01:00
Pavan Kumar Sunkara
43909ddefc
Fix some docs for app settings
2021-06-16 02:54:49 +01:00
Peter Kolloch
171dcbe424
setting: IgnoreErrors - Reaction to review comments
...
https://github.com/clap-rs/clap/pull/2480
2021-06-14 10:26:23 +02:00
Peter Kolloch
b0310e2d6e
settings: IgnoreErrors - prefix debug statements with fn name
2021-06-14 10:26:23 +02:00
Peter Kolloch
c50d338962
setting: IgnoreErrors - Allow parsing despite missing option values
...
Implemented as AppSetting::Ignore errors as suggested by
@CreepySkeleton in
https://github.com/clap-rs/clap/issues/1880#issuecomment-637779787 .
This is not a complete implementation but it works already in
surprisingly many situations.
https://github.com/clap-rs/clap/issues/1880
2021-06-14 10:26:18 +02:00
Tshepang Lekhonkhobe
e3bfa50e8f
docs: fix links to Subcommand ( #2518 )
...
* docs: fix links to Subcommand
These were broken by 03333800fe
* docs: remove crate links from body content
Addresses code review
* docs: allow some room to breath
Addresses code review
2021-06-07 11:19:45 +01:00
rami3l
6e158d9f8d
refactor(validator): cleanup code ( #2512 )
...
* refactor(validator): use filtermap style for `gather_conflicts` and `validate_exclusive`
* refactor(validator): remove nested `filter`s in `build_conflict_err_usage`
* refactor(validator): add more code beautifying
* refactor(validator): revert some unnecessary changes
* refactor(validator): revert some unnecessary changes, take 2
2021-06-07 00:45:45 +01:00
Terts Diepraam
6a574bf73c
Fix documentation for InferLongArgs
...
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2021-06-06 12:32:32 +02:00
Terts Diepraam
834f600a6f
infer long arguments
2021-06-05 13:18:06 +02:00
Pavan Kumar Sunkara
82e42cd07e
Ignore extra fields in YAML only when specified
2021-06-01 21:59:44 +01:00
rami3l
a91ca7fc1b
refactor(parser): encode all parsing state of FlagSubCommand
in Parser
2021-05-29 21:26:21 +02:00
rami3l
65b3892ef6
docs: add more explanation to #2501 fix ( #2507 )
...
* fix(parser): replace `unwrap` with `expect`
* docs(parser): add more comments explaining `done_short_args`
* docs(parser): add more comments explaining `keep_state`
2021-05-28 21:51:00 +01:00
rami3l
fbd338ce26
fix: flag_subcommands
unexpected behavior after long arg ( #2501 )
...
* fix(wip): add necessary debugging prints for analysis
* fix(wip): implement the fix, take 1
* docs: add docstring for `Parser::flag_subcmd_at` and `Parser::flag_subcmd_skip`
* test: make `flag_subcommand_short_after_long_arg` test more realistic
2021-05-27 05:14:50 +05:30
Pavan Kumar Sunkara
6a395d3208
ArgMacthes::is_present should not deal with subcommands at all, fixes #2494
2021-05-26 00:40:38 +01:00
Ajeet D'Souza
5809ae6060
feat: Add AppSettings::DisableEnv ( #2493 )
...
* Add DisableEnv flag
* Apply formatting
* Add tests
2021-05-21 00:47:47 +05:30
Ajeet D'Souza
460459c771
fix(usage): Move positional args to end of usage string ( #2492 )
...
* Move positional args to end of USAGE
* Remove -- from usage string
2021-05-21 00:29:21 +05:30
Eldritch Cheese
fa991754d3
imp(validator): Case-insensitive required_if_eq when arg is case-insensitive
2021-05-15 09:45:24 -07:00
Peter Kolloch
e89f1e6c4d
Input.insert: No need to clone
2021-05-13 13:29:01 +02:00
liudingming
529c55f753
Relax trait bound on clap Error source
2021-05-08 01:56:13 +08:00
liudingming
64e226ef33
Add multiple_* parsing for yaml
2021-05-07 14:34:03 +08:00
sharnoff
5ec28b6093
add missing $crate::
in clap_app!
2021-04-25 19:00:19 -07:00
Pavan Kumar Sunkara
9c99c358c6
Merge pull request #2440 from reaganmcf/app-setting-subcommand-help-long-form
...
setting: UseLongFormatForHelpSubcommand
2021-04-13 04:42:51 +05:30
Reagan McFarland
b184dc001b
setting: SubcommandHelpShowsLongForm implemented
...
Refactoring and better test cases
Refactored SubcommandHelpShowsLongForm to
UseLongFormatForHelpSubcommand.
Tests and docuemntation examples use about and long_about instead of
(before/after)_help.
Removed commented out tests
Linting: Fix trailing new line
Updated change log, refactored tests and doc str
Reordered items in the Changelog
New test added and old tests removed that were redundant
Doc string for AppSettings::UseLongFormatForHelpSubcommand fixed
2021-04-11 14:31:40 -04:00
Pavan Kumar Sunkara
3c9cc0cf91
Specify dep patch versions
2021-04-11 10:38:13 +01:00
Pavan Kumar Sunkara
52814b893c
Merge pull request #2415 from cbzehner/ignore-extra-fields-on-arg
...
Ignore extra fields in Arg yaml definitions
2021-03-14 14:00:30 +05:30
Pavan Kumar Sunkara
4e3b4589ee
Merge pull request #2411 from clap-rs/upgrader
...
Cleanup and add changelog
2021-03-14 14:00:16 +05:30
Chris Zehner
407e629523
Ignore extra fields in Arg yaml definitions
2021-03-13 19:46:38 -06:00
Pavan Kumar Sunkara
d9fb11eba2
Apply cargo-intraconv
2021-03-13 14:11:47 +05:30
Pavan Kumar Sunkara
f029047c03
Rename NoEmptyValues to ForbidEmptyValues
2021-03-13 12:05:34 +05:30
ldm0
d36b201fd6
Apply suggestions
2021-03-11 05:22:08 +00:00
ldm0
a1d4bd8488
Allow empty value by default, introduce NoEquals Error
2021-03-10 17:39:50 +00:00
Pavan Kumar Sunkara
30d784ffd1
Merge pull request #2400 from ldm0/unset-default
...
Support unsetting/removing the default if an option/flag is set
2021-03-10 18:13:52 +05:30
ldm0
448ff95fb0
ldm0's patch
2021-03-09 19:06:44 +00:00
Steven Engler
766dec8319
fixup! feat(build/arg/mod.rs): default_vals_if supports an Option as the default
2021-03-09 18:15:20 +00:00
Steven Engler
6626365359
feat(build/arg/mod.rs): default_vals_if supports an Option as the default
2021-03-09 18:15:20 +00:00
ldm0
2b0f0d3e1a
Implement NoEquals error
2021-03-09 17:56:57 +00:00
Pavan Kumar Sunkara
42c03775b5
Merge pull request #2395 from loloicci/improve-doc-error-exit
...
Improve the document of exit of parse::Errors
2021-03-09 23:20:04 +05:30
loloicci
06c2187f9e
docs: improve the document of exit of parse::Error
2021-03-09 23:37:45 +09:00
ldm0
0b1d137ee9
Apply suggestions
2021-03-09 13:52:12 +00:00
ldm0
6df56ad289
Move checker to macro(better panic message)
2021-03-09 13:45:11 +00:00
ldm0
886b873709
Demangle interlinking flags
2021-03-09 13:45:11 +00:00
ldm0
2bedad2bfa
Split debug_asserts from Arg
2021-03-09 13:45:11 +00:00
loloicci
0a6f086b8e
feat: implement print to parse::Error
...
Implement print to parse::Error.
It just prints formatted error messages and does not exit program.
2021-03-09 18:27:04 +09:00
Pavan Kumar Sunkara
09009761ec
Merge pull request #2368 from integer32llc/more-getters
...
Allow getting the long about, env, and default values of an argument
2021-03-05 22:53:28 +05:30
Jake Goulding
30840d6f35
Allow getting the long about, env, and default values of an argument
...
Closes #2367
2021-03-05 11:02:18 -05:00
Christoph Prokop
676a2d24b6
Fix code example to match help text
...
Signed-off-by: Christoph Prokop <christoph.prokop@mailbox.org>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Reviewed-by: Matthias Beyer <mail@beyermatthias.de>
2021-03-05 10:04:37 +01:00
dylni
8a6881169b
Upgrade os_str_bytes
2021-03-01 17:58:53 -05:00
Omar El Halabi
701a4610b3
feat: Implement Arg::required_if_eq_all
2021-02-28 14:52:34 +02:00
Logan SQUIREL
3c049b4e22
Fix compatibility with help2man output (see #1432 )
...
Change default help template:
- The new template introduce new lines before and after
author/about sections.
- Add help template placeholders:
- about-section
- author-section
- Documentation of new placeholders in clap::App::help_template
- Update all unit tests by incorporating new lines
2021-02-27 16:20:52 +01:00
Andreas Molzer
c6ea3720ab
Optimize common case of space padding
2021-02-25 13:26:39 +01:00
Logan SQUIREL
f74af655ce
Apply @pksunkara review
2021-02-22 09:37:29 +01:00
Logan SQUIREL
22b5d34693
imp: Visible aliases for arguments in completions ( #2335 )
...
Following changes are implemented:
- Add 'clap::Arg::get_visible_aliases(&self)' method
This new method provides access to visible argument aliases
- Add 'clap::Arg::get_short/long_and_visible_aliases
This new method provides access to the short/long arguments and its
visible aliases
- Add visible aliases completions in clap_generate for following shells:
- Bash
- Elvish
- Fish
- Powershell
- Zsh
- Add test fixtures for testing visible alias completions in clap_generate:
'clap_generate/tests/completions/<shell>::<shell>_with_aliases()'
2021-02-22 09:36:08 +01:00
Pavan Kumar Sunkara
1602b103cd
Fix typo in crate_license
docs
2021-02-20 22:08:48 +00:00
Martin Geisler
df7a8c1282
feat: remove direct unicode-width dependency
...
This removes the direct dependency on unicode-width and delegates the
complexity of computing the displayed width of text to the Textwrap
crate.
The `display_width` function handles characters like “æøå” (Danish),
“äöü” (German), and “😂 ✨ 😍 ” (emojis) – even if the unicode-width
Cargo feature is disabled.
This is an improvement of the former `str_width` function which would
over-estimate the width of emojis and non-ASCII characters (since they
are several bytes wide).
2021-02-20 20:56:15 +01:00
Pavan Kumar Sunkara
80cbc1e695
Merge pull request #2350 from ldm0/num_vals
...
Change how num_vals, min_vals, max_vals interacts with Multiple*
2021-02-18 21:07:26 +00:00
ldm0
2d26f02605
Add --all-features for CI, fix build with debug feature.
2021-02-17 04:37:08 +00:00
ldm0
28b58af63b
Change to num_vals, min_vals, max_vals interacts with Multi*
2021-02-16 03:45:20 +00:00
Collin Styles
2b45011c9b
Update docs for required_unless_present_any
( #2347 )
...
* docs: Correct method name in example
This looks like it was copied from the documentation for
`required_unless_present_all` but not updated accordingly for this
method.
* docs: Add note re `required_unless_present_all` to `required_unless_present_any`
There's a note in the documentation for `required_unless_present_all`
telling users to check out `required_unless_present_any` if that's what
they want. I figured it might be useful to have a similar note in the
documentation for `required_unless_present_any` pointing to that method
as well.
* docs: Fix `required` link in docs for `required_unless_present_all`
* docs: Correct "if" to "unless"
2021-02-15 08:20:11 +00:00
ldm0
73c682b652
Small code shrinking
2021-02-14 13:07:21 +00:00
ldm0
5cff16b6f9
Limit usage of inc_occurence_of
2021-02-14 11:21:12 +00:00
ldm0
78d7252b03
Remove Parser::need_more_vals
2021-02-14 11:21:12 +00:00
Pavan Kumar Sunkara
a8c9d28ead
Merge pull request #2346 from ldm0/non_fmt_panic_fix
...
Fix part of the non_fmt_panic warnings, bump version-sync to 0.9.2
2021-02-14 01:58:26 +00:00
Pavan Kumar Sunkara
5025ed3bee
Merge pull request #2345 from ldm0/usize
...
Change some u64 to usize
2021-02-14 01:57:53 +00:00
ldm0
ddb53af5dc
Change some u64 to usize
2021-02-13 15:25:40 +00:00
ldm0
580d8d2c63
Fix part of the non_fmt_panic
2021-02-12 17:35:15 +00:00
Pavan Kumar Sunkara
6634444c3c
Remove Arg::settings to be consistent with App
2021-02-12 10:42:38 +00:00
Pavan Kumar Sunkara
8eb5081b53
Update changelog
2021-02-10 23:33:14 +00:00
Pavan Kumar Sunkara
2b5a23597a
Better help message support for hidden and heading stuff
2021-02-08 05:22:27 +00:00
Pavan Kumar Sunkara
3758bba5e2
Remove help_about in favor of mut_arg
2021-02-07 17:22:56 +00:00
Pavan Kumar Sunkara
b824e0b088
Allow nested subcommands mutated generated args to take preference
2021-02-07 16:28:49 +00:00
Pavan Kumar Sunkara
423e2dde00
Remove version_about in favor of mut_arg
2021-02-07 16:14:07 +00:00
Pavan Kumar Sunkara
1bd902370a
Add tests for mut_arg on help and version
2021-02-07 15:54:24 +00:00
Pavan Kumar Sunkara
93a737a4fa
Merge pull request #2333 from clap-rs/build_help_and_version_at_start
...
Build help and version args at the beginning
2021-02-07 15:53:45 +00:00
Pavan Kumar Sunkara
c9cb22905c
Build help and version args at the beginning
2021-02-07 14:46:38 +00:00
ldm0
899b04f481
Remove clone
2021-02-07 05:40:02 +00:00
ldm0
1494109795
Apply rename suggestions
2021-02-07 05:32:35 +00:00
ldm0
fb3033834b
Change the way parser do self override
2021-02-07 04:46:56 +00:00
Donough Liu
58b9f35771
Add tests, fix grouped_values_of()
...
Fix clippy
type complexity fix
2021-02-07 04:46:56 +00:00
Donough Liu
451c5382cc
Finish arg grouping logic
2021-02-07 04:46:56 +00:00
Donough Liu
b48ccff812
Better MatchedArg::ty
2021-02-07 04:46:56 +00:00
Donough Liu
fdafa3f02a
More convenient MatchesArg functions
2021-02-07 04:46:56 +00:00
Donough Liu
7782a5eefc
Insert vals group for default missing vals
2021-02-07 04:46:56 +00:00
Donough Liu
32e03a0dfe
Better flow
2021-02-07 04:46:56 +00:00
Donough Liu
f1e9b82584
Implement nested vals
2021-02-07 04:46:56 +00:00
Donough Liu
9c52e454e8
Refactor MatchedArg::vals
2021-02-07 04:46:56 +00:00
Donough Liu
18549df845
Refactor MatchedArg::indices
2021-02-07 04:46:56 +00:00
ldm0
1000c9fb03
Fix eagerly trimming dash in parse_long_flag
2021-02-06 11:26:20 +00:00
Donough Liu
00cf697d36
Small simplification on several functions
2021-02-05 10:07:46 +00:00
Donough Liu
5e020c636d
Remove had_eq
2021-02-05 10:07:46 +00:00
Donough Liu
751adaa687
Remove ContainsLast flag
2021-02-05 10:07:46 +00:00
Donough Liu
818f62bd5c
Unused clippy allow
2021-01-30 17:39:34 +00:00
Donough Liu
45753d552b
Resolve a TODO
2021-01-30 17:39:34 +00:00
Donough Liu
cf4881182a
Add comments for some internal app settings
2021-01-30 17:39:34 +00:00
Donough Liu
c8e669c690
Eliminate unreachable branch
...
comment fix
Apply fmt
2021-01-30 17:39:33 +00:00
Donough Liu
944fc759c9
Optimize branch, more comments
2021-01-30 17:24:11 +00:00
Donough Liu
5774eb2c52
Simplify possible subcommand
2021-01-30 17:24:11 +00:00
Donough Liu
9cf007378b
Branch simpification
2021-01-30 17:24:11 +00:00
Donough Liu
336f926ec9
Integrate workflow
2021-01-30 17:24:11 +00:00
Donough Liu
be314d9ac0
Flow optimize
2021-01-30 17:24:11 +00:00
Donough Liu
c39dcf2ecf
Remove redundant ClapResult in some functions
2021-01-30 17:24:11 +00:00
Donough Liu
1b63516e3b
Flow reordering
2021-01-30 17:24:11 +00:00
Donough Liu
47eee8ab2f
Acc a request
2021-01-30 17:24:11 +00:00
Donough Liu
c6bcfe819e
Clearer error processing
2021-01-30 17:24:11 +00:00
Donough Liu
8f4c26fc58
Minor redundant logic cleanup
...
Fix clippy
dot fix
2021-01-30 17:24:09 +00:00
Pavan Kumar Sunkara
8d5a021e1e
Merge pull request #2309 from ldm0/parser0
...
Dehack, Revert #1856
2021-01-30 14:52:02 +00:00
ldm0
5ee6e07858
Fix usage of positional grouped arguments uses arg name rather than val_name
2021-01-24 19:02:43 +00:00
Donough Liu
0df169bbdc
Fix incorrect error message.
...
Comment out regressed logic
Fix clippy
2021-01-23 14:51:40 +00:00
Donough Liu
90d786b8bc
Dehack, revert #1856
2021-01-23 14:51:40 +00:00
Pavan Kumar Sunkara
d7f6748887
Merge pull request #2306 from ldm0/unset_setting
...
Fix unset_setting()
2021-01-23 13:37:57 +00:00
Bowen Ding
3907e11621
Make @group accept multiple attributes ( #2248 )
...
* Make @group accept multiple attributes.
* New syntax: remove parenthese and "=>".
* Fix example
* Make Clippy happy
* Make clippy happy again
2021-01-23 13:12:40 +00:00
ldm0
68a0ef930a
Fix copied code
2021-01-23 06:41:11 +00:00
AriusX7
448c102f4f
fix: allow visible alias(es) in yaml files
2021-01-20 02:17:17 +05:30
Pavan Kumar Sunkara
42a4087220
Merge pull request #2299 from ldm0/terminator
...
Pick up missing setting
2021-01-18 22:13:20 +00:00
Donough Liu
09f43594b9
Fix doc test
2021-01-19 02:39:16 +08:00
Donough Liu
acdb94c1a5
Add assert to make doc test fails.
2021-01-19 02:37:07 +08:00
Donough Liu
6968f340c3
Fix clippy warnings
2021-01-19 02:24:58 +08:00
Donough Liu
c6da968ec7
Bump textwrap to 0.13.2
2021-01-02 13:15:50 +08:00
Martin Geisler
72884b2642
docs: Mention correct default value in term_width docstring
...
The default was correctly changed to 100 in #1950 , but later
accidentally reverted in 89fcc75
.
2020-12-31 08:55:56 +01:00
Pavan Kumar Sunkara
a0269a41d4
Merge pull request #2268 from ldm0/fixme
...
Better mkeymap
2020-12-28 10:09:27 +00:00
Donough Liu
0f115f18ad
Fix positional count usage
2020-12-27 04:11:30 +08:00
Donough Liu
120e942e7a
Private arg
2020-12-27 01:46:48 +08:00
Donough Liu
2b7fd731ae
Private keys
2020-12-27 01:20:53 +08:00
Donough Liu
f54328ee4c
Cleaner api and better inner documentation
2020-12-27 00:43:49 +08:00
Donough Liu
53fdc9d6b2
Fix clippy
2020-12-26 21:03:21 +08:00
Donough Liu
ad3d3a13cd
KeyType: PartialEq for u64
2020-12-26 21:03:21 +08:00
Donough Liu
b2a066b24f
Resolve a fixme, better code readability
2020-12-26 21:03:21 +08:00
budde25
c26d1a4421
imp: added more derives to common App, Arg, and ArgMatches
2020-12-23 17:26:53 -06:00
budde25
52635f00d4
docs(arg_matches.rs): clarified unclear behavior for is_present and value_of methods
2020-12-23 07:44:19 -06:00
Pavan Kumar Sunkara
4bd15c45d2
Merge pull request #2253 from ldm0/global
...
Propagate global arg in subcommand to subsubcommand
2020-12-14 02:20:34 +00:00
Pavan Kumar Sunkara
c4ab996339
Merge pull request #2252 from ldm0/lazy_propagation
...
Lazy propagation and _build cleaning
2020-12-12 16:56:09 +00:00
Donough Liu
1965b9f866
Add BinNameBuilt flag to App
2020-12-13 00:11:12 +08:00
Donough Liu
2f9846d048
Lazy subcommand propagation, avoid redundant _build() function call
...
rustfmt and clippy
Indepth cleaning
Apply suggestions
2020-12-12 22:32:20 +08:00
Donough Liu
fa9be84b18
Propagate global arg in subcommand to subsubcommand
2020-12-12 22:20:16 +08:00
Donough Liu
5f5474d803
Fix only one arg printed in multiple required_unless missing situation
2020-12-12 12:57:17 +08:00
Donough Liu
6fdad97a90
Remove unused flag
2020-12-10 00:58:11 +08:00
Donough Liu
e58f89b3ab
Remove LowIndexMultiplePositional, stop repeatedly calc positional_count
2020-12-10 00:51:18 +08:00
Robin Moussu
6898fbde33
Automatically read license field from Cargo.toml
2020-12-09 00:16:19 +01:00
Donough Liu
573dc245e6
Fix incorrect error message.
2020-12-09 01:12:58 +08:00
Jonas Platte
041bfda7ca
Fix a typo in the Clap trait docs ( #2243 )
...
* Fix a typo in the Clap trait docs
* Update src/derive.rs
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-12-08 01:40:18 +00:00
Pavan Kumar Sunkara
3c93f276b5
Merge pull request #2230 from ahkrr/master
...
refactor: TODO 1.46.0, improve readability by using [] operator
2020-11-28 13:11:50 +00:00
Pavan Kumar Sunkara
c8184470ff
Merge pull request #2140 from ldm0/validator_fixme
...
Resolve a FIXME
2020-11-28 13:11:38 +00:00
Pavan Kumar Sunkara
b89163afb6
Update MSRV to 1.46
2020-11-28 11:58:28 +00:00
hk
bb7c9896b0
refactor: TODO 1.46.0, improve readability by using [] operator
2020-11-28 11:38:34 +01:00
Donough Liu
cad893ed04
Resolve a FIXME
2020-11-28 18:31:42 +08:00
arthmis
a97e24630d
chore: changing unrequired to non-required
2020-11-27 15:37:26 -05:00
arthmis
1b4a4596f6
docs: fixing a typo
2020-11-27 15:19:03 -05:00
arthmis
4e6a371851
chore: changing awkward grammar for positional argument error message
2020-11-27 15:12:28 -05:00
Pavan Kumar Sunkara
d36d91173d
Merge pull request #2191 from ahkrr/master
...
fix(clap_generate): zsh completion generation panic
2020-11-26 18:36:41 +00:00
Pavan Kumar Sunkara
821d79aac7
Merge pull request #1878 from lu-zero/update_from_arg_matches
...
Add update_from_arg_matches to FromArgMatches
2020-11-14 12:38:16 +01:00
Luca Barbato
3e51839383
Rename the update trait methods
2020-11-14 10:58:30 +01:00
Luca Barbato
5d342a7438
Update to the new from_subcommand logic
2020-11-14 10:17:13 +01:00
Luca Barbato
a9276576d7
wip: Add a variant for augment* for updates
2020-11-14 10:17:13 +01:00
Luca Barbato
8b6255057d
wip: Complete update_subcommand
...
external subcommand updating is equivalent to replace it
2020-11-14 10:17:13 +01:00
Luca Barbato
646b3fe811
wip: Add tests and user-facing functions
2020-11-14 10:17:13 +01:00
Luca Barbato
d1fc83a8fa
wip: Add update_from_arg_matches to FromArgMatches
2020-11-14 10:17:13 +01:00
hk
895c903b61
refactor: adding get_global, making two functions private
...
preserving the observable behavior of the existing
public api, while handling global arguments separately in
get_arg_conflicts_with
2020-11-09 15:29:00 +01:00
ldm0
ff3b23824d
Fix wrong StrictUTF8 handling when AllowExternalSubcommands
2020-11-08 19:06:32 +00:00
Donough Liu
93b9bd9162
Apply suggestions
2020-11-08 23:06:24 +08:00
Donough Liu
407cdac8e0
Refactor: remove a persistent parser state ValidNegNumFound
2020-11-08 16:05:07 +08:00
Donough Liu
3c2f60c9f3
Remove unreachable branch in use_long_arg()
2020-11-08 16:05:07 +08:00
Donough Liu
7aa2358d6e
Simplify is_new_arg()
2020-11-08 16:05:07 +08:00
Donough Liu
b1c7785810
Remove replace variable
...
Resolve TODO
Small refactors
More descriptive replaced item recovering
2020-11-08 16:05:03 +08:00
Donough Liu
5e4b4f4196
Remove invalid suggestion on using subcommand after positional argument
2020-11-07 20:32:28 +08:00
Donough Liu
2b1f47f975
Reduce osstring construction
2020-11-07 16:43:14 +08:00
Donough Liu
020b07b77b
Typo fix
2020-11-07 16:43:14 +08:00
Donough Liu
582db739c8
Shrink
2020-11-07 16:43:14 +08:00
Donough Liu
f17b29acbb
Make Arg::env()
and Arg::env_os()
takes_value(false)
by default
2020-11-06 21:51:39 +01:00
hk
5650e37969
fix: compatability with rustc 1.42.0
...
fixup!
2020-11-05 13:08:04 +01:00
hk
1b451f62ad
fix(clap_generate): zsh completion generation panic
...
zsh completion generation would panic if a global argument
had conflicts with another argument which was present in its
own command but not in its subcommands
2020-10-30 21:04:17 +01:00
bors[bot]
97b4fb639f
Merge #2165
...
2165: Help & Version settings r=pksunkara a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-10-28 06:27:49 +00:00
Pavan Kumar Sunkara
5dd9584119
Improve the logic for help & version building & parsing
2020-10-26 12:13:03 +01:00
Donough Liu
a19bfa1c35
Consistently wrap help and subcommand messages(with refactoring)
2020-10-25 22:43:01 +01:00
KBR9
625c201f65
Add docs about conflicts_with_all usage in yaml
...
add note about conflicts_with yaml option
add note about conflicts_with yaml option
fix wrapping
remove unnecessary sentence
remove note from conflicts_with
2020-10-24 21:54:01 +02:00
Pavan Kumar Sunkara
e8a06e79cd
Rename setting VersionlessSubcommands => DisableVersionForSubcommands
2020-10-24 16:04:49 +02:00
Pavan Kumar Sunkara
d6e2246aab
Rename setting DisableVersion => DisableVersionFlag
2020-10-24 16:03:12 +02:00
Pavan Kumar Sunkara
45f0ee8b55
Rename setting DisableHelpFlags => DisableHelpFlag
2020-10-24 16:03:12 +02:00
CastilloDel
88ac1f1803
Add assertions for required and default simultaneously
...
Add the suggested changes
Fix test issue_1050_num_vals_and_defaults
It used a required which isn't needed for the purpose of the test.
Add tests for the default+required assertions
Add test for positional args with long or short
2020-10-24 12:10:07 +01:00
bors[bot]
1d0b21908f
Merge #2178
...
2178: Various documentation fixes r=pksunkara a=cstyles
Co-authored-by: Collin Styles <collingstyles@gmail.com>
2020-10-18 22:08:05 +00:00
Collin Styles
0d4e2e5f9d
docs: remove links in documentation for requires_all
...
These links were broken but rather than fix them, let's just remove them
since they're inside the documentation for the function that they link
to which seems unnecessary.
2020-10-18 12:05:33 -07:00
Collin Styles
5b74d84f3c
docs: remove links in documentation for requires_if
functions
...
These links were broken but rather than fix them, let's just remove them
since they're inside the documentation for the functions that they link
to which seems unnecessary.
2020-10-18 12:05:32 -07:00
Collin Styles
3d5e1d987a
docs: add a bunch of missing links to the docs for Arg::env
2020-10-18 12:05:31 -07:00
Collin Styles
ba89a253fc
docs: remove link to allow_hyphen_values
...
This link was broken but rather than fix it, let's just remove it since
it's inside the documentation for the function that it links to which
seems unnecessary.
2020-10-18 12:05:30 -07:00
Collin Styles
8522b9c1cf
docs: fix another typo and add a missing link for Last
2020-10-18 12:05:29 -07:00
Collin Styles
eadecc5c1d
docs: add missing link in ArgGroup
documentation
2020-10-18 12:05:28 -07:00
Collin Styles
096338d163
docs: correct typo in ErrorKind
documentation
2020-10-18 12:05:27 -07:00
Collin Styles
75c1fdb707
docs: fix various copy-paste errors related to default_value
functions
2020-10-18 12:05:26 -07:00
Collin Styles
f7837b2ac0
docs: change single quotes to backticks
...
Pretty sure these are just typos.
2020-10-18 12:05:25 -07:00
Collin Styles
9f3cbcd149
docs: wrap Arg in backticks instead of quotes
...
This looks better and is more consistent with the rest of the
documentation.
2020-10-18 12:05:22 -07:00
Collin Styles
b3caf81918
docs: fix a bunch of broken documentation links
2020-10-18 12:05:19 -07:00
CastilloDel
acd3293af2
Add an assertion for positional args defining long or short
...
Also update the docs to reflect that Arg.index shouldn't be
used with long or short
2020-10-18 19:51:13 +01:00
Jacob Mischka
b3e638ad44
Add option to hide autogenerated env section from help text
2020-10-17 16:48:35 -05:00
bors[bot]
d2dd54b555
Merge #2172
...
2172: Don't use default value when option is passed r=pksunkara a=davidhewitt
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2020-10-14 20:54:10 +00:00
David Hewitt
94f6889116
Don't use default value when option is passed
2020-10-14 20:00:40 +01:00
Wim Looman
b31df047b8
Attach validation error as Error::source
2020-10-13 22:13:04 +02:00
bors[bot]
5a1a209965
Merge #2161
...
2161: Fix parser skipping options without heading set r=pksunkara a=CertainLach
Co-authored-by: Yaroslav Bolyukin <iam@lach.pw>
2020-10-11 08:55:33 +00:00
Donough Liu
7f627fceee
Change MissingArgumentOrSubcommand to DisplayHelpOnMissingArgumentOrSubcommand and don't use stderr
2020-10-11 15:42:47 +08:00
bors[bot]
4f90f3e4bb
Merge #2166
...
2166: Sort options base on option's short and long representation r=ldm0 a=ldm0
Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-10-10 18:54:49 +00:00
Donough Liu
15c77150a9
Sort options base on option's short and long representation
2020-10-11 02:08:10 +08:00
Marti Raudsepp
cda89a2af1
Fix typos and grammar
...
Some more fixes in addition to 594c535ba2
* Some I noticed manually.
* Some were found by Topy (https://github.com/intgr/topy ), either new
rules from Typo or new code in clap.
* `etc.` and `e.g.` rules were disabled during the last run.
2020-10-10 16:22:05 +03:00
Donough Liu
c9a407aa54
Fix: Don't mention unused subcommands (Partly cherry pick ef92e2b
)
...
Add `\t` for consistency
2020-10-10 03:34:28 +08:00
bors[bot]
4ff4879400
Merge #2154
...
2154: Fix the error logic and error message for suggesting `--` before a flag r=pksunkara a=ldm0
Co-authored-by: Donough Liu <ldm2993593805@163.com>
2020-10-09 19:05:13 +00:00
Yaroslav Bolyukin
6050a17024
fix : #2022
...
Parser was skipping default values for options with headings
Signed-off-by: Yaroslav Bolyukin <iam@lach.pw>
2020-10-09 23:45:11 +05:00
Donough Liu
9766aa11b1
Remove redundant(wrong) error processing
...
Argument prefixed by `-` will never inferred as a subcommand
Suggest using subcommand when supplied after `--`
Cargo fmt, adding test for wrongly using subcommand after `--`
Fix test
Fix clippy
2020-10-10 00:06:50 +08:00
Donough Liu
5815246fd9
Fix the error logic and error message for suggesting -- before a flag
...
Fix tests
Add test for issue #1284
Apply nitpicks
2020-10-10 00:04:22 +08:00
Pavan Kumar Sunkara
8131ead04b
More changelog and consistency
2020-10-09 17:05:51 +02:00
Pavan Kumar Sunkara
b931e25c79
Update MSRV to 1.42
2020-10-09 17:04:46 +02:00
bors[bot]
91633741e9
Merge #2143
...
2143: api(App): Adds help_about method to App. r=pksunkara a=pretzelhammer
Co-authored-by: pretzelhammer <7769424+pretzelhammer@users.noreply.github.com>
2020-09-26 06:55:58 +00:00
pretzelhammer
523729d3fc
api(App): Adds version_about method to App.
...
Version about text is now customizable and propagates to subcommands. Closes #1640 .
2020-09-25 09:06:35 -04:00
bors[bot]
87c9699931
Merge #2135
...
2135: fix(help messages): escape values in help messages r=pksunkara a=ninewise
Co-authored-by: Felix Van der Jeugt <felix.vanderjeugt@posteo.net>
2020-09-25 09:16:05 +00:00
Felix Van der Jeugt
d5c7c7d8bd
Fix clippy errors
2020-09-25 10:38:35 +02:00
pretzelhammer
33caf49793
api(App): Adds help_about method to App.
...
Help about text is now customizable and propagates to subcommands. Closes #2080 .
2020-09-24 17:53:02 -04:00
Felix Van der Jeugt
a083953d3a
Suggest corrections with double quotes
2020-09-24 17:58:35 +02:00
Pavan Kumar Sunkara
99b8830d0b
Remove unneeded cfg_attr
2020-09-24 13:51:02 +02:00
Pavan Kumar Sunkara
d881a1185b
Release 3.0.0-beta.2
...
clap@3.0.0-beta.2
clap_derive@3.0.0-beta.2
clap_generate@3.0.0-beta.2
Generated by cargo-workspaces
2020-09-18 20:32:41 +02:00
Felix Van der Jeugt
0f42344685
fix(help messages): escape whitespace values in help messages
2020-09-16 15:51:33 +02:00
bors[bot]
03c11607b5
Merge #2132
...
2132: Add missing links in docs. r=pksunkara a=newAM
Co-authored-by: Alex M <alexmgit@protonmail.com>
2020-09-12 18:28:23 +00:00
Alex M
96db338697
Add missing links in docs.
2020-09-12 10:15:14 -07:00
Alex M
3758725dc2
Fix for issue #2130 .
2020-09-12 09:52:52 -07:00
bors[bot]
3e9ee86713
Merge #2118
...
2118: Rename r=CreepySkeleton a=pksunkara
Co-authored-by: Pavan Kumar Sunkara <pavan.sss1991@gmail.com>
2020-08-29 11:22:13 +00:00
bors[bot]
61786c4971
Merge #2117
...
2117: Remove useless code r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-29 10:58:07 +00:00
Pavan Kumar Sunkara
55abd639f7
Rename get_*_no_heading to get_*_with_no_heading
2020-08-29 11:49:04 +02:00
Pavan Kumar Sunkara
9e381f92a9
Rename required_unless_eq_* to required_unless_present_*
2020-08-29 11:48:35 +02:00
CreepySkeleton
ccb1ea2d65
Remove useless code
...
This code does not serve any purpose as far as I can tell
2020-08-29 00:44:11 +03:00
CreepySkeleton
3a099a6627
Implement std::error::Error for clap::Error
2020-08-28 20:57:39 +03:00
bors[bot]
e4b5407296
Merge #1976 #2073
...
1976: Refactor r=pksunkara a=CreepySkeleton
2073: Add new "regex" feature r=CreepySkeleton a=bkaestner
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
Co-authored-by: Benjamin Kästner <benjamin.kaestner@gmail.com>
2020-08-28 17:14:31 +00:00
CreepySkeleton
5020333037
Refactor coloring
2020-08-28 19:21:05 +03:00
Benjamin Kästner
cde1a2d218
regex: Introduce convenience Cow-wrapper RegexRef
...
As previously discussed on [GitHub], this commit introduces a Cow-like
wrapper RegexRef to enable both `Regex` as well as `&Regex` as
arguments.
It also introduces a new module in the `build:arg` path to remove
clutter from the main module. For more information see #2073 .
[GitHub]: https://github.com/clap-rs/clap/pull/2073#issuecomment-674442310
2020-08-26 17:54:54 +02:00
Benjamin Kästner
8cb9a7d486
Add new "regex" feature
...
This commit introduces a new feature called `"regex"`. It adds a new
function `validator_regex` to `Arg` and was inspired by the discussion
in #1968 . The name `validator_regex` was chosen instead of
`regex_validator` to make sure that the developer keeps in mind that
there may only be a single `Validator` on an `Arg`.
The feature can be used with YAML files, however there is no proper
pattern in `clap_app!` (yet).
2020-08-26 17:54:54 +02:00
Sergey Dubovyk
d525be42c5
chore: use if instead of matching
...
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-25 11:07:19 +03:00
knidarkness
530b179776
fix: detect if space should be added before spec_vals
2020-08-25 10:41:08 +03:00
bors[bot]
29df5c2d16
Merge #2100 #2106
...
2100: Allow for nested subcommands with ZSH generation. r=pksunkara a=newAM
2106: Update the env var example for derive r=pksunkara a=rgreinho
Co-authored-by: Alex M <alexmgit@protonmail.com>
Co-authored-by: Rémy Greinhofer <remy.greinhofer@gmail.com>
2020-08-24 06:45:45 +00:00
bors[bot]
7853903052
Merge #2102
...
2102: Fix propagation r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-24 06:22:27 +00:00
CreepySkeleton
1cd069090e
Fix propagation
2020-08-23 20:56:29 +03:00
Alex M
60dfcf13b5
Allow for nested subcommands with ZSH generation.
2020-08-23 09:33:29 -07:00
Simon Morgan
2e973a2649
Fix a few documentation typos
2020-08-22 16:49:09 +01:00
CreepySkeleton
28ad25fe66
Ensure the lifetime is 'static
2020-08-21 08:41:50 +03:00
CreepySkeleton
fd1ee7872e
Make caching in crate_authors! actually work
2020-08-21 08:21:21 +03:00
bors[bot]
ed3bb993c5
Merge #2087
...
2087: refactor: Avoid second traversal and unwrap r=pksunkara a=phimuemue
Co-authored-by: philipp <descpl@yahoo.de>
2020-08-21 03:56:53 +00:00
aspen
96b7fd454b
Forbid all unsafe code.
2020-08-20 18:38:40 -04:00
philipp
86dc14f5cd
refactor: Avoid second traversal and unwrap
2020-08-20 19:32:53 +02:00
Danil Kondratiev
4878f7b7b1
don't print spaces in long help
2020-08-20 17:25:36 +03:00
bors[bot]
1e3d53fd1f
Merge #2081
...
2081: Polish doc comments for App r=CreepySkeleton a=mkantor
Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-17 20:56:13 +00:00
bors[bot]
025ec3c28b
Merge #2078
...
2078: Unify naming cheme r=pksunkara a=CreepySkeleton
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-17 20:35:05 +00:00
Matt Kantor
f6e28c5ff0
Remove doc mention of no-longer-existing from_yaml method.
2020-08-17 12:54:24 -07:00
Matt Kantor
494fddd06e
Polish doc comments for App.
...
- Fix some links.
- Make the punctuation consistent.
- Correct some spelling/grammar mistakes.
2020-08-17 11:00:00 -07:00
tomjw64
27771ceeb7
Show arguments in conflict message in reverse order of input
2020-08-16 03:47:19 -05:00
tomjw64
97149e37f5
Remove underscore prefix for build_conflict_err_usage
2020-08-16 03:42:58 -05:00
tomjw64
35f761e699
Extract extra logic to _build_conflict_err_usage
2020-08-15 17:58:47 -05:00
CreepySkeleton
f4fb9db65c
cargo fmt
2020-08-16 00:29:30 +03:00
CreepySkeleton
0b2eac4da7
Fix yaml support
2020-08-15 23:42:23 +03:00
CreepySkeleton
ce3171ace5
Arg::required_unless_all => required_unless_eq_all
2020-08-15 20:38:57 +03:00
CreepySkeleton
b12102c832
Arg::required_unless -> required_unless_present
2020-08-15 20:38:56 +03:00
CreepySkeleton
55dceca819
Improve documentation
2020-08-15 20:38:56 +03:00
CreepySkeleton
233af6e7a1
Arg::required_if => required_if_eq
2020-08-15 20:38:55 +03:00
CreepySkeleton
8b85c4ecea
Arg::required_ifs => required_if_eq_any
2020-08-15 20:38:12 +03:00
CreepySkeleton
6b6b6035ed
Arg::required_unless_one => required_unless_eq_any
2020-08-15 20:38:11 +03:00
tomjw64
481229fffd
Remove stray print
2020-08-15 04:49:53 -05:00
tomjw64
826db05319
Add test for three argument conflict output
2020-08-15 04:43:12 -05:00
tomjw64
6602feb9e6
Also include required arguments in conflict output
2020-08-15 04:17:28 -05:00
tomjw64
937e14f6e8
Remove latter conflicting arg from usage message
2020-08-15 03:17:16 -05:00
bors[bot]
26aa746c3a
Merge #2067
...
2067: Use a template to produce the default help message r=pksunkara a=mkantor
Co-authored-by: Matt Kantor <the.matt.kantor@gmail.com>
2020-08-14 23:42:38 +00:00
Matt Kantor
85d3daa8c1
Use a different default template when there are no args.
...
This eliminates extraneous empty lines when there are no user-defined
args, the default args are disabled, and `after_help` is set.
2020-08-14 14:02:52 -07:00
Matt Kantor
4545a47ff6
Fix: {before-help} should have fallback just like {after-help}.
2020-08-14 13:58:37 -07:00