Expand description
Builder Pattern
To construct a Commander
a Builder
is used. It allows chaining together the common actions, whilst also construct the structure of the tree in an ergonomic manner.
The builder pattern is supported by the BuilderChain
trait, which is implemented on the Builder
struct, and also the common result type BuilderResult
.
This allows for chaining methods without needing to intersperse .unwrap()
or .expect()
calls everywhere.
§Example
use cmdtree::*;
let cmder = Builder::default_config("cmdtree-example")
.begin_class("class1", "class1 help message")
.begin_class("inner-class1", "nested class!")
.add_action("name", "print class name", |_, _| println!("inner-class1", ))
.end_class()
.end_class()
.into_commander().unwrap();
Structs§
- Builder
- The persistent
Builder
structure to construct aCommander
command tree. See module level documentation for more information.
Enums§
- Build
Error - Error variants when building a
Commander
.
Traits§
- Builder
Chain - The common functions across a
Builder
or aBuilderResult
. See module level documentation for more information.
Type Aliases§
- Builder
Result - The common result of
BuilderChain
functions.