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): Add additional group methods
This adds the ability derive additional options for the group creation. Needed for clap-rs#4574.
- Loading branch information
Showing
6 changed files
with
64 additions
and
35 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
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,23 @@ | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(name = "basic", subcommand)] | ||
struct Opt { | ||
#[command(flatten)] | ||
source: Source, | ||
} | ||
|
||
#[derive(clap::Args, Debug)] | ||
#[group(required = true, name = "src")] | ||
struct Source { | ||
#[arg(short)] | ||
git: String, | ||
|
||
#[arg(short)] | ||
path: 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,7 @@ | ||
error: `#[group(required = true, name = "src")]` does not support name | ||
--> $DIR/group_name_attribute.rs:3:10 | ||
| | ||
11 |#[group(required = true, name = "src")] | ||
| ^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the derive macro `group` (in Nightly builds, run with -Z macro-backtrace for more info) |