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: impl IntoIterator<Item = impl Into<OsString>>,
)
pub fn insert( &mut self, cursor: &ArgCursor, insert_items: impl IntoIterator<Item = impl Into<OsString>>, )
Inject arguments before the RawArgs::next
Trait Implementations§
impl Eq for RawArgs
impl StructuralPartialEq for RawArgs
Auto Trait Implementations§
impl Freeze for RawArgs
impl RefUnwindSafe for RawArgs
impl Send for RawArgs
impl Sync for RawArgs
impl Unpin for RawArgs
impl UnwindSafe for RawArgs
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