Struct RawArgs

struct RawArgs { ... }

Command-line arguments

Implementations

impl RawArgs

fn from_args() -> Self

NOTE: The argument returned will be the current binary.

Example

# use std::path::PathBuf;
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:?}");
fn new<impl Into<OsString>: Into<OsString>, impl IntoIterator<Item = impl Into<OsString>>: IntoIterator<Item = impl Into<OsString>>>(iter: impl IntoIterator<Item = impl Into<OsString>>) -> Self

Example

# use std::path::PathBuf;
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:?}");
fn cursor(self: &Self) -> ArgCursor

Create a cursor for walking the arguments

Example

# use std::path::PathBuf;
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:?}");
fn next(self: &Self, cursor: &mut ArgCursor) -> Option<ParsedArg<'_>>

Advance the cursor, returning the next ParsedArg

fn next_os(self: &Self, cursor: &mut ArgCursor) -> Option<&OsStr>

Advance the cursor, returning a raw argument value.

fn peek(self: &Self, cursor: &ArgCursor) -> Option<ParsedArg<'_>>

Return the next ParsedArg

fn peek_os(self: &Self, cursor: &ArgCursor) -> Option<&OsStr>

Return a raw argument value.

fn remaining(self: &Self, cursor: &mut ArgCursor) -> impl Iterator<Item = &OsStr>

Return all remaining raw arguments, advancing the cursor to the end

Example

# use std::path::PathBuf;
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:?}");
fn seek(self: &Self, cursor: &mut ArgCursor, pos: SeekFrom)

Adjust the cursor's position

fn insert<impl Into<OsString>: Into<OsString>, impl IntoIterator<Item = impl Into<OsString>>: IntoIterator<Item = impl Into<OsString>>>(self: &mut Self, cursor: &ArgCursor, insert_items: impl IntoIterator<Item = impl Into<OsString>>)

Inject arguments before the RawArgs::next

fn is_end(self: &Self, cursor: &ArgCursor) -> bool

Any remaining args?

impl Clone for RawArgs

fn clone(self: &Self) -> RawArgs

impl Debug for RawArgs

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl Default for RawArgs

fn default() -> RawArgs

impl Eq for RawArgs

impl Freeze for RawArgs

impl PartialEq for RawArgs

fn eq(self: &Self, other: &RawArgs) -> bool

impl RefUnwindSafe for RawArgs

impl Send for RawArgs

impl StructuralPartialEq for RawArgs

impl Sync for RawArgs

impl Unpin for RawArgs

impl UnsafeUnpin for RawArgs

impl UnwindSafe for RawArgs

impl<I, T> From for RawArgs

fn from(val: I) -> Self

impl<T> Any for RawArgs

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for RawArgs

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for RawArgs

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for RawArgs

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for RawArgs

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for RawArgs

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for RawArgs

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for RawArgs

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for RawArgs

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>