pub struct ArgParser { /* private fields */ }Implementations§
Source§impl ArgParser
impl ArgParser
pub fn new() -> Self
pub fn args(&mut self, arg_type: ArgType, arg_count: ArgCount) -> &mut Self
pub fn flag(&mut self, flags: &[&str]) -> &mut Self
pub fn optional_flag(&mut self, flags: &[&str]) -> &mut Self
pub fn arg_flag(&mut self, flag: &str, arg_type: ArgType) -> &mut Self
pub fn optional_arg_flag(&mut self, flag: &str, arg_type: ArgType) -> &mut Self
pub fn arg_flag_with_default( &mut self, flag: &str, default: &str, arg_type: ArgType, ) -> &mut Self
pub fn flag_with_default(&mut self, flags: &[&str]) -> &mut Self
pub fn short_flag(&mut self, flags: &[&str]) -> &mut Self
pub fn alias(&mut self, from: &str, to: &str) -> &mut Self
Sourcepub fn parse(
&self,
raw_args: &[String],
skip_first_n: usize,
) -> Result<ParsedArgs, Error>
pub fn parse( &self, raw_args: &[String], skip_first_n: usize, ) -> Result<ParsedArgs, Error>
Let’s say raw_args is ["rag", "ls-files", "--json", "--staged", "--name-only"] and
you don’t care about the first 2 args (path and command name). You only want to parse
the flags (the last 3 args). In this case, you set skip_first_n to 2.
Auto Trait Implementations§
impl Freeze for ArgParser
impl RefUnwindSafe for ArgParser
impl Send for ArgParser
impl Sync for ArgParser
impl Unpin for ArgParser
impl UnwindSafe for ArgParser
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