Struct CommandLine

Source
pub struct CommandLine { /* private fields */ }
Expand description

Represents a command-line app.

Implementations§

Source§

impl CommandLine

Source

pub fn new(root: Command) -> Self

Constructs a new CommandLine with the provided Command.

Source

pub fn with_context(context: Context) -> Self

Constructs a new CommandLine with the provided Context.

Source

pub fn context(&self) -> &Context

Returns the Context used by this command-line.

Source

pub fn root(&self) -> &Command

Returns the Command used by this command-line.

Source

pub fn suggestions(&self) -> Option<&SuggestionSource>

Returns the SuggestionProvider used by this command-line.

Source

pub fn use_default_help(self) -> Self

Sets the default Help.

Source

pub fn use_default_suggestions(self) -> Self

Sets the default SuggestionProvider.

Source

pub fn use_suggestions(self, suggestions: SuggestionSource) -> Self

Sets the SuggestionSource of this command-line context.

Source

pub fn use_help(self, help: HelpSource) -> Self

Sets the HelpSource of this command-line context.

Source

pub fn use_help_option(self, option: CommandOption) -> Self

Sets the help option for this command-line context.

Source

pub fn use_help_command(self, command: Command) -> Self

Sets the help command for this command-line context.

Source

pub fn use_version_option(self, option: CommandOption) -> Self

Sets the version option for this command-line context.

Source

pub fn use_version_command(self, command: Command) -> Self

Sets the version command for this command-line context.

Source

pub fn parse_args(&mut self) -> Result<ParseResult>

Parse the program arguments get the ParseResult after handling any help, version or suggestion messages.

Source

pub fn parse_from<S, I>(&mut self, args: I) -> Result<ParseResult>
where S: Borrow<str>, I: IntoIterator<Item = S>,

Parse given arguments get the ParseResult after handling any help, version or suggestion messages.

Source

pub fn run(&mut self) -> Result<()>

Parse the program arguments and runs the app.

This is equivalent to CommandLine::parse_from(std::env::args().skip(1)).

Source

pub fn run_from<S, I>(&mut self, args: I) -> Result<()>
where S: Borrow<str>, I: IntoIterator<Item = S>,

Parses the given arguments and runs the app.

Trait Implementations§

Source§

impl Debug for CommandLine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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.