diff options
| author | Matthew Hall <hallmatthew314@gmail.com> | 2024-03-28 21:53:53 +1300 |
|---|---|---|
| committer | Matthew Hall <hallmatthew314@gmail.com> | 2024-03-28 21:53:53 +1300 |
| commit | cda07006720dc53367d0a552aa2c77796825f82d (patch) | |
| tree | 00c155cbf3815350c8edf7825ad54a0dc6cb5153 /src | |
| parent | 8e33cc5dae9abbbf3e7a0371fcdc98f699481c1b (diff) | |
Implement fully-random category option
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 8 insertions, 0 deletions
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<DropIn>), @@ -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::<Vec<&str>>(); 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) |
