From 6ca0569baa1226c032949d3896ea8edc41c6018b Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 30 Sep 2022 08:14:24 -0500 Subject: [PATCH] fix(derive): Pipe group attribute through Still doesn't support any attributes within it yet. --- clap_derive/src/attr.rs | 7 +++---- clap_derive/src/item.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/clap_derive/src/attr.rs b/clap_derive/src/attr.rs index df2ab5685d5..f97ba7d0a7f 100644 --- a/clap_derive/src/attr.rs +++ b/clap_derive/src/attr.rs @@ -35,10 +35,7 @@ impl ClapAttr { } else if attr.path.is_ident("command") { Some(Sp::new(AttrKind::Command, attr.path.span())) } else if attr.path.is_ident("group") { - abort!( - attr.path.span(), - "`#[group()]` attributes are not supported yet" - ) + Some(Sp::new(AttrKind::Group, attr.path.span())) } else if attr.path.is_ident("arg") { Some(Sp::new(AttrKind::Arg, attr.path.span())) } else if attr.path.is_ident("value") { @@ -202,6 +199,7 @@ pub enum AttrKind { Clap, StructOpt, Command, + Group, Arg, Value, } @@ -212,6 +210,7 @@ impl AttrKind { Self::Clap => "clap", Self::StructOpt => "structopt", Self::Command => "command", + Self::Group => "group", Self::Arg => "arg", Self::Value => "value", } diff --git a/clap_derive/src/item.rs b/clap_derive/src/item.rs index 758df901a37..5494097520d 100644 --- a/clap_derive/src/item.rs +++ b/clap_derive/src/item.rs @@ -291,7 +291,7 @@ impl Item { ), }); } - AttrKind::Arg | AttrKind::Clap | AttrKind::StructOpt => {} + AttrKind::Group | AttrKind::Arg | AttrKind::Clap | AttrKind::StructOpt => {} } self.name = Name::Assigned(quote!(#arg)); } else if name == "name" { @@ -309,7 +309,11 @@ impl Item { ), }); } - AttrKind::Command | AttrKind::Value | AttrKind::Clap | AttrKind::StructOpt => {} + AttrKind::Group + | AttrKind::Command + | AttrKind::Value + | AttrKind::Clap + | AttrKind::StructOpt => {} } self.name = Name::Assigned(quote!(#arg)); } else if name == "value_parser" {