Skip to content

How to set default to stdin? #3437

Answered by epage
x10an14 asked this question in Q&A
Feb 10, 2022 · 1 comments · 15 replies
Discussion options

You must be logged in to vote

You can declare the positional argument optional via bar: Option<String> and key off of that for reading from stdin.

If bar were a path, I would do

#[clap(value_name = "PATH", default_value = "-", parse(from_os_str))]
input: std::path::PathBuf,

Replies: 1 comment 15 replies

Comment options

You must be logged in to vote
15 replies
@x10an14
Comment options

@epage
Comment options

@alkeryn
Comment options

@epage
Comment options

@alkeryn
Comment options

Answer selected by x10an14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants