Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(derive): Support 'group' attribute with Parser #4310

Merged
merged 1 commit into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion clap_derive/src/lib.rs
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
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