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

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

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

Required methods

fn begin_class<H: Into<CmdStr>>(
    self,
    name: &str,
    help_msg: H
) -> BuilderResult<R>

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

fn end_class(self) -> BuilderResult<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<H: Into<CmdStr>, F: FnMut(&mut dyn Write, &[&str]) -> R + Send + 'static>(
    self,
    name: &str,
    help_msg: H,
    closure: F
) -> BuilderResult<R>

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

fn root(self) -> BuilderResult<R>

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

fn into_commander(self) -> Result<Commander<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<R> BuilderChain<R> for Builder<R>[src]

impl<R> BuilderChain<R> for BuilderResult<R>[src]

Loading content...