Module bpaf::_documentation::_1_tutorials::_2_derive_api
source · Expand description
Derive API tutorial
Create a parser by defining a structure
When making a parser using Derive API you should go though approximately following steps:
- Design data type your application will receive
- Design command line options user will have to pass
- Add
#[derive(Bpaf, Debug, Clone)]
on top of your type or types - Add #[bpaf(xxx)] annotations on types and fields
- And
#[bpaf(options)]
to the top type - Run the resulting parser
Let’s go though some of them in more details:
- Getting started with derive macro
- Customizing flag and argument names
- Customizing the consumers
- Transforming parsed values
- Parsing structs and enums
- What gets generated
- Making nested parsers
- Parsing subcommands
- Making a cargo command