Struct App

Source
pub struct App {
    pub name: String,
    pub version: String,
    pub author: String,
    pub args: HashMap<String, Vec<String>>,
}
Expand description

A public struct for your awesome CLI app!

Fields§

§name: String§version: String§author: String§args: HashMap<String, Vec<String>>

Implementations§

Source§

impl App

Implementing all methods for your app that give you the freedom to choose what you’d like to do.

Source

pub fn new(name: String, version: String, author: String) -> App

Instantiates the “App” struct.

Source

pub fn arg_was_used(&self, arg: String) -> bool

Checks if “-a” or “–arg” was used.

Source

pub fn add_arg(&mut self, name: String, help: String, data: String)

Adds an argument to the argument pool. If you’d like to accept data for an argument, set the “data” flag to either “true” or “false”.

Source

pub fn get_arg_data(&self, name: String) -> String

Retrieves the command line data for an argument.

Source

pub fn version_is(&self) -> bool

Returns a boolean to tell you whether version info was requested or not.

Source

pub fn help_is(&self) -> bool

Returns a boolean to tell you whether help info was requested or not.

Source

pub fn version(&self) -> String

Returns a string with version info.

Source

pub fn clean_split(&self, subject: String, split_char: String) -> Vec<String>

Helper function to split strings into vectors.

Source

pub fn help(&self) -> String

Returns a string with help info.

Auto Trait Implementations§

§

impl Freeze for App

§

impl RefUnwindSafe for App

§

impl Send for App

§

impl Sync for App

§

impl Unpin for App

§

impl UnwindSafe for App

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.