bolt::program

Struct Program

Source
pub struct Program {
    pub cmds: Vec<Command>,
    pub version: String,
    pub author: String,
    pub about: String,
}
Expand description

The crux of the whole cli, contains a commands field that stores all the program commands in a vector

Fields§

§cmds: Vec<Command>

Holds all the possible commands of the program

§version: String

Contains the version information of the program

§author: String

Contains the author’s name

§about: String

A simple string containing the tagline of the program

Implementations§

Source§

impl Program

Source

pub fn new() -> Self

Creates a new instance of the program with an empty vector for the cmds field

Source

pub fn add_cmd() -> Command

This method is used to register a new command to the program

Source§

impl Program

Source

pub fn init(&mut self)

This function is called when the program starts, it creates all the commands of the program.

Source

pub fn parse(&mut self, args: &Vec<String>) -> Option<Vec<&Command>>

Source

pub fn validate_args(arguments: &Vec<String>, cmds: &Vec<Command>) -> bool

Source

pub fn output_help(cmds: &Vec<Command>, err: &str)

Outputs help for the program, and prints the error if any is passed

Source

pub fn output_version()

Simply prints the version information for the program

Source

pub fn output_command_help(cmd: &Command, err: &str)

Outputs help information for a speficic command and prints an optional error

Trait Implementations§

Source§

impl Default for Program

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.