pub struct Command<'a> { /* private fields */ }
Expand description
Command represents a command parsed from the command-line Use CliBuilder to build a parsed Command
§Example
use kern::CliBuilder;
use std::env;
let args: Vec<String> = env::args().collect();
let command = CliBuilder::new().options(&["option"]).build(&args);
assert_eq!(command.command().contains("rustdoctest"), true);
Implementations§
source§impl<'a> Command<'a>
impl<'a> Command<'a>
sourcepub fn parameters(&self) -> &HashMap<&'a str, &'a str>
pub fn parameters(&self) -> &HashMap<&'a str, &'a str>
Get all parameters
sourcepub fn parameter<T: FromStr>(&self, name: &str, default: T) -> T
pub fn parameter<T: FromStr>(&self, name: &str, default: T) -> T
Get specific parameter or default
sourcepub fn param(&self, name: &str, default: &'a str) -> &str
pub fn param(&self, name: &str, default: &'a str) -> &str
Get specific parameter or default as &str
sourcepub fn argument<T: FromStr>(&self, index: usize, default: T) -> T
pub fn argument<T: FromStr>(&self, index: usize, default: T) -> T
Get argument at specific index or default
sourcepub fn arg(&self, index: usize, default: &'a str) -> &str
pub fn arg(&self, index: usize, default: &'a str) -> &str
Get argument at specific index or default as &str
sourcepub fn without_options(raw: &'a [String]) -> Self
👎Deprecated
pub fn without_options(raw: &'a [String]) -> Self
Create a new Command from raw command line arguments without options
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Command<'a>
impl<'a> Send for Command<'a>
impl<'a> Sync for Command<'a>
impl<'a> Unpin for Command<'a>
impl<'a> UnwindSafe 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