pub struct MaybeStdin<T> { /* private fields */ }
Expand description
Wrapper struct to parse arg values from stdin
MaybeStdin
can wrap any type that matches the trait bounds for Arg
: FromStr
and Clone
use std::path::PathBuf;
use clap::Parser;
use clap_stdin::MaybeStdin;
#[derive(Debug, Parser)]
struct Args {
path: MaybeStdin<PathBuf>,
}
if let Ok(args) = Args::try_parse() {
println!("path={}", args.path.display());
}
$ pwd | ./example -
/current/working/dir
Implementations§
Source§impl<T> MaybeStdin<T>
impl<T> MaybeStdin<T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the inner value from the wrapper
Trait Implementations§
Source§impl<T: Clone> Clone for MaybeStdin<T>
impl<T: Clone> Clone for MaybeStdin<T>
Source§fn clone(&self) -> MaybeStdin<T>
fn clone(&self) -> MaybeStdin<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T> Debug for MaybeStdin<T>where
T: Debug,
impl<T> Debug for MaybeStdin<T>where
T: Debug,
Source§impl<T> Deref for MaybeStdin<T>
impl<T> Deref for MaybeStdin<T>
Source§impl<T> DerefMut for MaybeStdin<T>
impl<T> DerefMut for MaybeStdin<T>
Source§impl<T> Display for MaybeStdin<T>where
T: Display,
impl<T> Display for MaybeStdin<T>where
T: Display,
Auto Trait Implementations§
impl<T> Freeze for MaybeStdin<T>where
T: Freeze,
impl<T> RefUnwindSafe for MaybeStdin<T>where
T: RefUnwindSafe,
impl<T> Send for MaybeStdin<T>where
T: Send,
impl<T> Sync for MaybeStdin<T>where
T: Sync,
impl<T> Unpin for MaybeStdin<T>where
T: Unpin,
impl<T> UnwindSafe for MaybeStdin<T>where
T: UnwindSafe,
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