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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes