Module bpaf::_documentation::_1_tutorials::_2_derive_api
source · Available on crate feature
extradocs
only.Expand description
§Derive API tutorial
Create a parser by defining a structure
When making a parser using Derive API you should go through 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 through some of them in more detail:
- 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