From cda07006720dc53367d0a552aa2c77796825f82d Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Thu, 28 Mar 2024 21:53:53 +1300 Subject: Implement fully-random category option --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 2fe5a26..4f299d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,7 @@ struct Args { #[derive(Debug, Clone)] enum DropIn { + Any, Basic(String), Var(String), OneOf(Vec), @@ -90,6 +91,10 @@ impl DropIn { return Err(Error::EmptyOption) } + if text == "?" { + return Ok(DropIn::Any); + } + if text.contains('|') { let mut option_strs = text.split('|').collect::>(); option_strs.dedup(); @@ -166,6 +171,9 @@ impl CategorySet { DropIn::OneOf(_) => { panic!("Nested OneOf constructs are not supported") }, + DropIn::Any => { + self.random_category()? + }, }; let words = self.categories.get_mut(&category) -- cgit v1.2.1