[][src]Trait cmdtree::builder::BuilderChain

pub trait BuilderChain<'a, R> {
    fn begin_class(self, name: &str, help_msg: &'a str) -> BuilderResult<'a, R>;
fn end_class(self) -> BuilderResult<'a, R>;
fn add_action<F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'a>(
        self,
        name: &str,
        help_msg: &'a str,
        closure: F
    ) -> BuilderResult<'a, R>;
fn root(self) -> BuilderResult<'a, R>;
fn into_commander<'c>(self) -> Result<Commander<'a, R>, BuildError>; }

The common functions across a Builder or a BuilderResult. See module level documentation for more information.

Required methods

fn begin_class(self, name: &str, help_msg: &'a str) -> BuilderResult<'a, R>

Start a new nested class. If the name already exists a BuildError will be returned.

fn end_class(self) -> BuilderResult<'a, R>

Close a class and move to it's parent. If no parent exists (this function is called on the root), a BuildError will be returned.

fn add_action<F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'a>(
    self,
    name: &str,
    help_msg: &'a str,
    closure: F
) -> BuilderResult<'a, R>

Add an action. The closure type gives the arguments after the action command as an array of strings.

fn root(self) -> BuilderResult<'a, R>

Navigates to the root class, closing out the classes as it goes.

fn into_commander<'c>(self) -> Result<Commander<'a, R>, BuildError>

Finishes the construction of the command tree and returns the build Commander.

Note

This can be called even when not on a root class. The implmentation will continue to call end_class until the root is reached, short-circuiting the closing out process.

If an error is propogating through then the function will error. If there was no error (ie into_commander was called on a Builder instance) then this function should not fail.

Loading content...

Implementors

impl<'a, R> BuilderChain<'a, R> for Builder<'a, R>[src]

impl<'a, R> BuilderChain<'a, R> for BuilderResult<'a, R>[src]

Loading content...