pub struct RawArgs { /* private fields */ }
Expand description
Command-line arguments
Implementations§
source§impl RawArgs
impl RawArgs
sourcepub fn from_args() -> Self
pub fn from_args() -> Self
NOTE: The argument returned will be the current binary.
Example
let raw = clap_lex::RawArgs::from_args();
let mut cursor = raw.cursor();
let _bin = raw.next_os(&mut cursor);
let mut paths = raw.remaining(&mut cursor).map(PathBuf::from).collect::<Vec<_>>();
println!("{:?}", paths);
sourcepub fn new(iter: impl IntoIterator<Item = impl Into<OsString>>) -> Self
pub fn new(iter: impl IntoIterator<Item = impl Into<OsString>>) -> Self
Example
let raw = clap_lex::RawArgs::new(["bin", "foo.txt"]);
let mut cursor = raw.cursor();
let _bin = raw.next_os(&mut cursor);
let mut paths = raw.remaining(&mut cursor).map(PathBuf::from).collect::<Vec<_>>();
println!("{:?}", paths);
sourcepub fn cursor(&self) -> ArgCursor
pub fn cursor(&self) -> ArgCursor
Create a cursor for walking the arguments
Example
let raw = clap_lex::RawArgs::new(["bin", "foo.txt"]);
let mut cursor = raw.cursor();
let _bin = raw.next_os(&mut cursor);
let mut paths = raw.remaining(&mut cursor).map(PathBuf::from).collect::<Vec<_>>();
println!("{:?}", paths);
sourcepub fn next(&self, cursor: &mut ArgCursor) -> Option<ParsedArg<'_>>
pub fn next(&self, cursor: &mut ArgCursor) -> Option<ParsedArg<'_>>
Advance the cursor, returning the next ParsedArg
sourcepub fn next_os(&self, cursor: &mut ArgCursor) -> Option<&OsStr>
pub fn next_os(&self, cursor: &mut ArgCursor) -> Option<&OsStr>
Advance the cursor, returning a raw argument value.
sourcepub fn remaining(&self, cursor: &mut ArgCursor) -> impl Iterator<Item = &OsStr>
pub fn remaining(&self, cursor: &mut ArgCursor) -> impl Iterator<Item = &OsStr>
Return all remaining raw arguments, advancing the cursor to the end
Example
let raw = clap_lex::RawArgs::new(["bin", "foo.txt"]);
let mut cursor = raw.cursor();
let _bin = raw.next_os(&mut cursor);
let mut paths = raw.remaining(&mut cursor).map(PathBuf::from).collect::<Vec<_>>();
println!("{:?}", paths);
sourcepub fn insert(&mut self, cursor: &ArgCursor, insert_items: &[&str])
pub fn insert(&mut self, cursor: &ArgCursor, insert_items: &[&str])
Inject arguments before the RawArgs::next