Skip to content

Commit

Permalink
fix(derive): Support 'group' attribute with Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 30, 2022
1 parent 106d8f5 commit 5f145a2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clap_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn value_enum(input: TokenStream) -> TokenStream {
/// receiving an instance of `clap::ArgMatches` from conducting parsing, and then
/// implementing a conversion code to instantiate an instance of the user
/// context struct.
#[proc_macro_derive(Parser, attributes(clap, structopt, command, arg))]
#[proc_macro_derive(Parser, attributes(clap, structopt, command, arg, group))]
#[proc_macro_error]
pub fn parser(input: TokenStream) -> TokenStream {
let input: DeriveInput = parse_macro_input!(input);
Expand Down
3 changes: 2 additions & 1 deletion tests/derive/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ For more information try '--help'
#[test]
fn skip_group_avoids_duplicate_ids() {
#[derive(Parser, Debug)]
#[group(skip)]
struct Opt {
#[command(flatten)]
first: Compose<Empty, Empty>,
Expand All @@ -88,7 +89,7 @@ fn skip_group_avoids_duplicate_ids() {
use clap::Args;
assert_eq!(Empty::group_id(), None);
assert_eq!(Compose::<Empty, Empty>::group_id(), None);
assert_eq!(Opt::group_id(), Some(clap::Id::from("Opt")));
assert_eq!(Opt::group_id(), None);
}

#[test]
Expand Down

0 comments on commit 5f145a2

Please sign in to comment.