Skip to main content

Command

Struct Command 

Source
pub struct Command<C = Context> { /* private fields */ }
Expand description

Command structure which represents command-line task.

Implementations§

Source§

impl<C> Command<C>

Command structure implementation.

Source

pub fn name(&self) -> &String

Returns name.

Source

pub fn about(&self) -> &Option<String>

Returns about.

Source

pub fn description(&self) -> &Option<String>

Returns description.

Source

pub fn author(&self) -> &Option<String>

Returns author.

Source

pub fn version(&self) -> &Option<String>

Returns version.

Source

pub fn flags(&self) -> &Vec<Flag>

Returns flags.

Source

pub fn params(&self) -> &Vec<Param>

Returns flags.

Source

pub fn resources(&self) -> &Vec<Resource>

Returns resources.

Source

pub fn commands(&self) -> &Vec<Command<C>>

Returns commands.

Source§

impl<C> Command<C>

Command structure implementation.

Source

pub fn with_name<S: Into<String>>(name: S) -> Self

Returns new instance.

Source

pub fn with_about<S: Into<String>>(self, val: S) -> Self

Sets about.

Source

pub fn with_description<S: Into<String>>(self, val: S) -> Self

Sets description.

Source

pub fn with_author<S: Into<String>>(self, val: S) -> Self

Sets about.

Source

pub fn with_version<S: Into<String>>(self, val: S) -> Self

Sets version.

Source

pub fn with_handler(self, handler: CommandHandler<C>) -> Self

Sets error handler function.

Source

pub fn with_resolver(self, resolver: CommandResolver<C>) -> Self

Sets resolver function.

Source

pub fn with_flag(self, flag: Flag) -> Self

Adds flag.

Source

pub fn with_param(self, param: Param) -> Self

Adds param.

Source

pub fn with_resource(self, resource: Resource) -> Self

Adds resource.

Source

pub fn with_subcommand(self, command: Command<C>) -> Self

Adds subcommand.

Source

pub fn run(self, ctx: &mut C) -> Result<i32>

Executes as a command-line application.

Source

pub fn run_args<A, T>(self, args: A, ctx: &mut C) -> Result<i32>
where A: IntoIterator<Item = T>, T: Into<String>,

Executes as a command-line application.

Auto Trait Implementations§

§

impl<C> Freeze for Command<C>

§

impl<C> RefUnwindSafe for Command<C>

§

impl<C> Send for Command<C>

§

impl<C> Sync for Command<C>

§

impl<C> Unpin for Command<C>

§

impl<C> UnsafeUnpin for Command<C>

§

impl<C> UnwindSafe for Command<C>

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.