Trait CommandSet

Source
pub trait CommandSet: FromStr + Display {
    // Required methods
    fn variants() -> Vec<String>;
    fn arguments(&self) -> &'static str;
    fn flags(&self) -> &'static str;
    fn desc(&self) -> &'static str;

    // Provided methods
    fn help_simple(&self) -> String { ... }
    fn help_all() -> String { ... }
}
Expand description

A CommandSet is a set of commands (usually an enum) that each represent an action that can be performed. i.e. ‘list’, ‘volume’ etc. Each command can take zero or more arguments and have zero or more flags. Typically an Enum of commands would implement CommandSet trait.

Required Methods§

Source

fn variants() -> Vec<String>

Returns a vector of strings that are the commands supported by this.

Source

fn arguments(&self) -> &'static str

Returns a string listing the arguments that this command takes, in <> brackets

Source

fn flags(&self) -> &'static str

Returns a string displaying the flags that this command supports, in [] brackets

Source

fn desc(&self) -> &'static str

Returns a short description of this command

Provided Methods§

Source

fn help_simple(&self) -> String

Help string for this variant (build from Display, arguments and flags by default)

Source

fn help_all() -> String

Possibly multi-line help string for all variants of this set.

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§