pacak / bpaf

Command line parser with applicative interface
Apache License 2.0
341 stars 17 forks source link

Support `fallback_to_usage` in derive macro #376

Closed pacak closed 1 month ago

pacak commented 1 month ago

You can specify them next to command annotation or options annotation. In either way if parser requires some arguments and user passed none - instead of producing "required ... not found" type of error bpaf will print the usage page for this parser or subcommand

Usage for option parser

#[derive(Debug, Clone, Bpaf)]
enum Commands {
    #[bpaf(command, fallback_to_usage)]
    Action {
        ...
    }
}

usage for subcommand

#[derive(Debug, Clone, Bpaf)]
#[bpaf(options, fallback_to_usage)]
struct Options {
    ...
}