Skip to content
Discussion options

You must be logged in to vote

You want something like this:

use bpaf::*;

#[derive(Debug, Copy, Clone, Bpaf)]
enum Foo {
    #[bpaf(command)]
    Meow,
    #[bpaf(command)]
    Bark,
}

#[derive(Debug, Copy, Clone, Bpaf)]
#[bpaf(options)]
enum Toplevel {
    #[bpaf(command)] // "foo" is a command, but its body is `external(foo)`
    Foo(#[bpaf(external(foo))] Foo),
    #[bpaf(command)]
    Bar,
}

fn main() {
    let r = toplevel().fallback_to_usage().run();
    match r {
        Toplevel::Foo(f) => match f {
            Foo::Meow => println!("Meow!"),
            Foo::Bark => println!("Bark"),
        },
        Toplevel::Bar => println!("bar!"),
    }
}

and #[bpaf(command)] complains that “method meta is private” (…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by GoldsteinE
Comment options

You must be logged in to vote
1 reply
@pacak
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #455 on June 22, 2026 16:54.