From 3138db2f4e71605c8c6ea8f277b0d97e2afacced Mon Sep 17 00:00:00 2001 From: Mroik Date: Mon, 16 Feb 2026 04:30:41 +0100 Subject: Fix passing quote by piping to stdin --- src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index db07ecf..efb530f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ struct Args { /// Turns all text into lowercase (NOOB mode) #[arg(short, long)] lower: bool, - quote: String, + quote: Option, } fn generate_quotes(path: &Path) -> Result, Box> { @@ -49,12 +49,14 @@ async fn main() -> Result<(), Box> { let mut b = Vec::new(); stdin().read_to_end(&mut b).unwrap(); String::from_utf8(b).unwrap() - } else { - let path = Path::new(&args.quote); + } else if let Some(q) = &args.quote { + let path = Path::new(q); let mut quotes = generate_quotes(path).unwrap(); let mut rng = thread_rng(); let chosen = rng.gen_range(0..quotes.len()); quotes.remove(chosen) + } else { + todo!() }; if args.lower { -- cgit v1.3