pub struct Command { /* private fields */ }Expand description
Sub command
Implementations§
Source§impl Command
impl Command
Sourcepub fn get_flag<T: AsRef<str>>(&self, names: &[T]) -> Option<Flag>
pub fn get_flag<T: AsRef<str>>(&self, names: &[T]) -> Option<Flag>
Get a flag by flag names
Examples found in repository?
examples/ecla.rs (line 41)
35fn main() {
36 let app = App::new(HELP, VERSION);
37
38 if let Some(_) = app.get_command("command") {
39 command();
40 } else if let Some(command) = app.get_command("flag") {
41 let flag = command.get_flag(&["-f", "--force"]);
42 if flag.is_some() {
43 command_with_flag(flag.unwrap().get_value());
44 } else {
45 command_with_no_flag();
46 }
47 } else if let Some(command) = app.get_command("value") {
48 command_with_value(command.get_value());
49 } else {
50 app.show_unknown_or_help();
51 }
52}Sourcepub fn get_value_array(&self) -> Option<Vec<String>>
pub fn get_value_array(&self) -> Option<Vec<String>>
Get sub command’s values
Sourcepub fn get_value(&self) -> Option<String>
pub fn get_value(&self) -> Option<String>
Get sub command’s value
Examples found in repository?
examples/ecla.rs (line 48)
35fn main() {
36 let app = App::new(HELP, VERSION);
37
38 if let Some(_) = app.get_command("command") {
39 command();
40 } else if let Some(command) = app.get_command("flag") {
41 let flag = command.get_flag(&["-f", "--force"]);
42 if flag.is_some() {
43 command_with_flag(flag.unwrap().get_value());
44 } else {
45 command_with_no_flag();
46 }
47 } else if let Some(command) = app.get_command("value") {
48 command_with_value(command.get_value());
49 } else {
50 app.show_unknown_or_help();
51 }
52}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnwindSafe for Command
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