Commit graph

110 commits

Author SHA1 Message Date
ldm0
2b0f0d3e1a Implement NoEquals error 2021-03-09 17:56:57 +00: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
Logan SQUIREL
cd8660fbd0
Fix issue #2181
- help / version flag report correct application name when generated
with clap_derive and an Enum.
- add clap_derive unit tests for application name:
  file: clap_derive/tests/app_name.rs
  tests: app_name_in_[short|long]_[help|version]_from_[struct|enum]()
2021-02-22 15:01:02 +01:00
ldm0
a684e9a51d Bump version-sync version 2021-02-14 09:51:23 +00:00
ldm0
580d8d2c63 Fix part of the non_fmt_panic 2021-02-12 17:35:15 +00:00
Pavan Kumar Sunkara
1bd902370a Add tests for mut_arg on help and version 2021-02-07 15:54:24 +00:00
Donough Liu
6968f340c3 Fix clippy warnings 2021-01-19 02:24:58 +08:00
David Yamnitsky
09014258cb Use clap instead of ::clap in clap_derive 2020-12-15 15:20:21 -05:00
Pavan Kumar Sunkara
ad9f97f402 Fix ui tests 2020-11-28 19:16:58 +00:00
Aaron Hill
6dc8353fe2
Fix hygiene of arg_matches parameter
In the `Clap` derive macro, a function parameter named `arg_matches` is
generated using `quote!` - as a result, this parameter ends up with
call-site hygiene. However, `arg_matches` is written literally within
several `quote_spanned!` blocks, which generate an `arg_matches` token
with the hygiene of whatever span was passed to `quote_spanned!`.

If these two hygienes are different (for example, if the user invokes
the derive macro from a `macro_rules!` macro), then a usage of
`arg_matches` may not resolve to the `arg_matches` parameter definition.

This commit changes the generation of `arg_matches` identifiers to
always use `quote!`, ensuring that they will always be considered the
'same' identifier by Rust.
2020-11-28 12:22:57 -05:00
Pavan Kumar Sunkara
56aeb155e1 Test rust regression 2020-11-28 11:47:18 +00:00
Luca Barbato
d18ff58391 Add a skip test 2020-11-14 11:09:39 +01:00
Luca Barbato
3e51839383 Rename the update trait methods 2020-11-14 10:58:30 +01:00
Luca Barbato
ac3e5f9a8f Factor out argument parsing generation 2020-11-14 10:53:13 +01:00
Luca Barbato
7a5c12e79a Avoid a level of indirection for augment_*subcommand 2020-11-14 10:17:13 +01:00
Luca Barbato
77e4e65e31 Address new clippy lints 2020-11-14 10:17:13 +01:00
Luca Barbato
9ebb46d65c Test for partial updates 2020-11-14 10:17:13 +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
Pavan Kumar Sunkara
d6e2246aab Rename setting DisableVersion => DisableVersionFlag 2020-10-24 16:03:12 +02:00
Wim Looman
b31df047b8 Attach validation error as Error::source 2020-10-13 22:13:04 +02:00
Marti Raudsepp
bc7cc4fbab Add examples for using value_hint with clap_derive
Also tweaked clap_generate example a little.
2020-10-10 00:11:44 +03:00
Pavan Kumar Sunkara
b931e25c79 Update MSRV to 1.42 2020-10-09 17:04:46 +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
bors[bot]
16f92288f1
Merge #2115
2115: Adjust stderr files r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-28 11:31:47 +00:00
CreepySkeleton
f97b4cb1c7 Adjust stderr files 2020-08-28 13:51:58 +03:00
bors[bot]
ebecccd009
Merge #2110
2110: Allow flatten with doc comments r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-08-26 07:13:34 +00:00
CreepySkeleton
a951958748 Allow flatten with doc comments 2020-08-25 20:20:56 +03:00
Rémy Greinhofer
2a2cf81977 Update the env var example for derive
Updates the derive example handling environment variables to illustrate
the case where it contains a sensitive value which should not be
displayed on the help screen.

Closes https://github.com/clap-rs/clap/issues/2101
2020-08-23 18:18:25 -05:00
aspen
96b7fd454b
Forbid all unsafe code. 2020-08-20 18:38:40 -04:00
Kevin K
609202e2a0 wip: clap_derive docs 2020-08-11 15:21:57 +02:00
CreepySkeleton
f0044d205d Remove a redundant lifetime 2020-08-05 22:33:51 +03:00
CreepySkeleton
e6cc49ecde Adjust derive 2020-08-05 17:07:13 +03:00
João Marcos
24760bc261 style: replacing yml with yaml for consistency 2020-07-20 20:58:34 -03:00
Marti Raudsepp
594c535ba2 Fix various typos in docs & code
Most errors detected and fixed with Topy (https://github.com/intgr/topy),
all verified by hand.
2020-07-19 03:10:28 +03:00
bors[bot]
e8d46f4036
Merge #1989
1989: Replace macros with proper functions r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-07-06 18:51:07 +00:00
CreepySkeleton
51d0b31105 Fix test 2020-07-06 17:26:53 +03:00
Aaron Hill
c837b28552
fix(clap_derive): Unwrap syn::TypeGroup when checking field types
Due to macro expansions, a `syn` type may be wrapped in multiple
'layers' of `syn::Type::Group`. However, `clap_derive` currently does
not check for `syn::Type::Group`, which will cause an `Option` (along
with other matched types) to fail to be detected when it results from a
macro expansion.

This commit 'unwraps' outer type groups before checking the
user-provided types against well-known types. Currently, these groups
may not be present due to a rustc bug (rust-lang/rust#43081)

However, once https://github.com/rust-lang/rust/pull/73084 is merged,
these groups will be present in more cases. This commit makes `clap`
compatible with both older and newer versions of rustc.
2020-06-29 11:25:55 -04:00
CreepySkeleton
f904bebd9a Ditch find_subcnd*! and match_alias! 2020-06-27 04:30:02 +03:00
bors[bot]
ca27d50ab2
Merge #1975
1975: fix: Use character instead of string for Arg::Short r=CreepySkeleton a=lanesawyer



Co-authored-by: Lane Sawyer <github@lanesawyer.dev>
2020-06-27 01:14:20 +00:00
Luca Barbato
081f3e865c Fix the external command subtype check 2020-06-25 13:52:14 +02:00
Lane Sawyer
392effe319 fix: Use character instead of string for Arg::Short
This PR switches the Arg::Short macro to take a character instead of a string. It removes the hacky code in the Method to_token method and implements the logic for Short when parsing the clap derive arguments.

Fixes #1815.
2020-06-17 09:45:05 -07:00
Pavan Kumar Sunkara
8bd1f1a9d3 Started on automatic upgrader 2020-06-10 09:48:37 +02:00
Andreas Steding
f3a9975085 fix: cargo fmt + clippy 2020-06-08 18:40:11 +02:00
Paolo Barbolini
d771d6debd chore(Cargo.toml): bump proc-macro-error to 1 2020-05-29 00:13:17 +02:00
Pavan Kumar Sunkara
fe52d77f4e Allow separate derives, but do not give examples 2020-05-15 09:51:42 +02:00
Pavan Kumar Sunkara
7bc282dd4e Rename with_name to new for Arg & ArgGroup 2020-05-14 22:50:56 +02:00