forked from clap-rs/clap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(derive): Allow users to opt-in to
ValueParser
For clap 3, its opt-in as a precaution against breaking compatibility in some weird cases. This does require the types to implement `Clone`. Fixes clap-rs#3734 Fixes clap-rs#3496 Fixes clap-rs#3589
- Loading branch information
Showing
5 changed files
with
147 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2018 Guillaume Pinot (@TeXitoi) <texitoi@texitoi.eu> | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(name = "basic")] | ||
struct Opt { | ||
#[clap(parse(from_str), value_parser = clap::value_parser!(String))] | ||
s: String, | ||
} | ||
|
||
fn main() { | ||
let opt = Opt::parse(); | ||
println!("{:?}", opt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
error: `value_parse` attribute conflicts with `parse` attribute | ||
--> tests/derive_ui/parse_with_value_parser.rs:14:29 | ||
| | ||
14 | #[clap(parse(from_str), value_parser = clap::value_parser!(String))] | ||
| ^^^^^^^^^^^^ |