pub struct Command<'a> {
pub command_pattern: CommandPattern<'a>,
pub arguments: Vec<String>,
pub options: Options,
}Expand description
Command generated from an appropriate defined CommandPattern. It stores information of the
result command based on Args, therefore Command is a result type, and not a container.
§Fields
- command_patterns: Original
CommandPatternfrom which thisCommandwas generated. It is stored in order to call itscallbackfield and to determine which command was matched. - arguments: Arguments generated following
CommandPattern’sargs_countfield. - options: Options generated following
CommandPattern’soption_patternsfield.
§Example
Command::new(
Args::CommandLineArgs,
&[
CommandPattern::new(
"exit",
&[], // No arguments are accepted.
&[], // No options are accepted.
&|_, _| std::process:exit(0),
),
],
)Fields§
§command_pattern: CommandPattern<'a>§arguments: Vec<String>§options: OptionsImplementations§
Source§impl<'a> Command<'a>
impl<'a> Command<'a>
Sourcepub fn from_args(
args: Args,
command_patterns: &[CommandPattern<'a>],
) -> Result<Self, String>
pub fn from_args( args: Args, command_patterns: &[CommandPattern<'a>], ) -> Result<Self, String>
Creates a new Command from commandargs’s Args.
§Fields
- args: Source of arguments used, refer to
Argsto know the possible variants that can be passed here. - command_patterns: Accepted
CommandPattern’s used to get a resultCommand.
§Example
Command::from_args(
Args::CommandLineArgs,
&[
CommandPattern::new(
"exit",
&[], // No arguments are accepted.
&[], // No options are accepted.
&|_, _| std::process:exit(0),
),
],
)Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Command<'a>
impl<'a> !Send for Command<'a>
impl<'a> !Sync for Command<'a>
impl<'a> !UnwindSafe for Command<'a>
impl<'a> Freeze for Command<'a>
impl<'a> Unpin for Command<'a>
impl<'a> UnsafeUnpin for Command<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more