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§
source§impl PartialEq for RawArgs
impl PartialEq for RawArgs
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