fallback_command/
fallback_command.rs

1//! Parse some commands manually or collect anything else as
2//! for manual parsing
3use bpaf::*;
4use std::ffi::OsString;
5
6#[derive(Debug, Clone, Bpaf)]
7#[bpaf(options)]
8#[allow(dead_code)]
9enum Commands {
10    #[bpaf(command)]
11    Build {
12        /// Optimization level
13        opt: u32,
14    },
15    Fallback(#[bpaf(external(fallback), hide)] Fallback),
16}
17
18#[derive(Debug, Clone, Bpaf)]
19#[allow(dead_code)]
20struct Fallback {
21    #[bpaf(positional("COMMAND"))]
22    name: String,
23
24    #[bpaf(any("ARG", Some))]
25    args: Vec<OsString>,
26}
27
28fn main() {
29    let opts = commands().run();
30    println!("{:?}", opts);
31}