Struct clap_stdin::FileOrStdin
source · pub struct FileOrStdin<T = String> {
pub source: Source,
/* private fields */
}
Expand description
Wrapper struct to either read in a file or contents from stdin
FileOrStdin
can wrap any type that matches the trait bounds for Arg
: FromStr
and Clone
use std::path::PathBuf;
use clap::Parser;
use clap_stdin::FileOrStdin;
#[derive(Debug, Parser)]
struct Args {
contents: FileOrStdin,
}
if let Ok(args) = Args::try_parse() {
println!("contents={}", args.contents);
}
$ cat <filename> | ./example -
<filename> contents
$ ./example <filename>
<filename> contents
Fields§
§source: Source
Source of the contents
Implementations§
source§impl<T> FileOrStdin<T>
impl<T> FileOrStdin<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 FileOrStdin<T>
impl<T: Clone> Clone for FileOrStdin<T>
source§fn clone(&self) -> FileOrStdin<T>
fn clone(&self) -> FileOrStdin<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T> Debug for FileOrStdin<T>where
T: Debug,
impl<T> Debug for FileOrStdin<T>where
T: Debug,
source§impl<T> Deref for FileOrStdin<T>
impl<T> Deref for FileOrStdin<T>
source§impl DerefMut for FileOrStdin
impl DerefMut for FileOrStdin
source§impl<T> Display for FileOrStdin<T>where
T: Display,
impl<T> Display for FileOrStdin<T>where
T: Display,
Auto Trait Implementations§
impl<T> RefUnwindSafe for FileOrStdin<T>where
T: RefUnwindSafe,
impl<T> Send for FileOrStdin<T>where
T: Send,
impl<T> Sync for FileOrStdin<T>where
T: Sync,
impl<T> Unpin for FileOrStdin<T>where
T: Unpin,
impl<T> UnwindSafe for FileOrStdin<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