Commit graph

4135 commits

Author SHA1 Message Date
Ed Page
2458d3934a test: Cover external subcommand updates
We don't know enough to do partial updates, so we are only doing full
updates.

Closes #2212
2021-08-13 12:33:12 -05:00
Ed Page
9a180c1511 feat(derive): Specify defaults by native expressions
Right now
- `default_value="something"` is a raw method
- `default_value` uses native types

This commit splits the meanings
- `default_value="something"` is a raw method
- `default_value_t` uses `T::default()`
- `default_value_t=expr` uses an expression that evaluates to `T`

This is meant to mirror the `value_of` / `value_of_t` API.

At the moment, this is limited to `T: Display` to work with clap's
default system.  Something we can look at in the future is a way to
loosen that restriction.  One quick win is to specialize when `arg_enum`
is set.  The main downside is complicating the processing of attributes
because it then means we need some processed before others.

Since this builds on `clap`s existing default system, this also means
users do not get any performance gains out of using `default_value_t`,
since we still need to parse it but we also need to convert it to a
string.

Fixes #1694
2021-08-13 12:20:54 -05: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
550e73d056
Merge pull request #2531 from pickfire/fix-flatten
Derive doc clap ordering for multiple Clap
2021-08-12 21:34:49 +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
33c305ea6f
Merge pull request #2681 from clap-rs/global-setting
Remove settings that are inherently global
2021-08-12 00:26:47 +01:00
Ivan Tham
f484e2da11 Derive doc clap ordering for multiple Clap
Fix #2527
2021-08-11 23:31:00 +01:00
Pavan Kumar Sunkara
6ae15a79b6 Remove settings that are inherently global 2021-08-11 22:41:25 +01:00
Pavan Kumar Sunkara
69d75949df
Merge pull request #2664 from rami3l/env-literal
feat(parser): accept boolean literal with env vars
2021-08-10 23:44:19 +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
Pavan Kumar Sunkara
6527fdeec4
Merge pull request #2671 from ldm0/tmp
Fix some work on `ArgStr`
2021-08-09 00:41:51 +01:00
liudingming
696f93c4f5 Fix some work on ArgStr 2021-08-09 04:26:01 +08:00
Pavan Kumar Sunkara
eabe828092
Merge pull request #2655 from ldm0/coverage
Parser refactor
2021-08-08 20:56:09 +01: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
Pavan Kumar Sunkara
10c7228b3f
Merge pull request #2667 from ldm0/tweak1
fmt::write -> push_str
2021-08-07 19:06:40 +01:00
liudingming
d2fec9128f fmt::write -> push_str 2021-08-08 00:25:51 +08:00
Pavan Kumar Sunkara
8b6034e668
Merge pull request #2663 from rami3l/docs-example
docs(example): clarify `stop_parsing_with_--`
2021-08-03 17:32:58 +01:00
rami3l
44ae55fa4e docs(example): clarify stop_parsing_with_-- 2021-08-03 13:41:54 +02:00
Pavan Kumar Sunkara
9e4ea7db17
Merge pull request #2660 from rami3l/fix-clippy
fix(style): eliminate several `clippy` warnings
2021-08-03 03:39:57 +01:00
rami3l
ac12c30352 fix(style): allow bool_assert_comparison in default_missing_value_flag_value 2021-08-02 23:10:51 +02:00
rami3l
d7c984896d fix(style): remove unnecessary usages of 'static and ref 2021-08-02 23:05:21 +02:00
rami3l
adc34a2680 fix(style): eliminate several clippy warnings 2021-08-02 22:31:59 +02:00
Pavan Kumar Sunkara
286fda0b4a
Merge pull request #2653 from patrick-gu/master
Make `multiple_values` `false` with derived `Option<Option<...>>`
2021-08-02 09:19:20 +01:00
patrick-gu
eca8ba6098 Make multiple_values false with Option<Option<...>> 2021-08-01 14:50:31 -07: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
d848c88773 fix(test): fix typo in flag_using_long_with_literals 2021-08-01 12:19:00 +02:00
rami3l
97999c2d96 docs(example): remove pseudo-flag example 2021-08-01 11:59:59 +02:00
rami3l
2b3fc4d0b6 test: simplify flag_using_long_with_literals 2021-08-01 11:57:44 +02:00
rami3l
cf94a5bffa docs(example): update pseudo-flag example 2021-08-01 11:49:37 +02:00
rami3l
7f8f5ccc9a Revert "fix(style): fix code format warning"
This reverts commit a4a4d4c307.
2021-08-01 11:41:29 +02:00
Pavan Kumar Sunkara
e649e1b731
Merge pull request #2650 from ldm0/coverage
Use llvm-cov for more accurate coverage report
2021-08-01 09:00:01 +01:00
Pavan Kumar Sunkara
25f6958c16
Merge pull request #2651 from AbyssAbuse/master
Make colorizer respect `AppSettings::ColorAlways` / `ColorChoice::Always`
2021-08-01 08:59:34 +01:00
liudingming
a711fc3cf2 Use llvm-cov for more accurate coverage report 2021-08-01 15:11:27 +08:00
Abyss
faa25f9e67 Make colorizer respect ColorChoice::Always 2021-07-31 18:12:54 -04:00
Pavan Kumar Sunkara
4abf5fefca
Merge pull request #2649 from ldm0/master
Fix `value_of` returns `None` when the first value group is empty
2021-07-31 22:57:22 +01: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