Trait HnCommand

Source
pub trait HnCommand {
    const NAME: &'static str;

    // Required methods
    fn parser<'a, 'b>() -> App<'a, 'b>;
    fn cmd(matches: &ArgMatches<'_>) -> Result<(), Box<dyn Error>>;
}
Expand description

A trait defining the interface to add a subcommand to the command line application.

Required Associated Constants§

Source

const NAME: &'static str

The name of this subcommand. Will be used at the command line interface to name this subcommand.

Required Methods§

Source

fn parser<'a, 'b>() -> App<'a, 'b>

A function which returns a clap App instance. This App will be used as a subcommand in the over all command line application structure.

Source

fn cmd(matches: &ArgMatches<'_>) -> Result<(), Box<dyn Error>>

The command executed when this subcommand is actually run. This function receives a clap ArgMatches instance, which can drive optional or argument based logic.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl HnCommand for HackerNews

Source§

const NAME: &'static str = "hackernews"