From 0c8f8653bba0fa63ceda5dfc0f5f5ba917e472e1 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Sat, 20 Jul 2019 12:37:07 -0400 Subject: Implement "salad" mode --- lib/jdtalk/core.d | 9 +++++++++ source/app.d | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/jdtalk/core.d b/lib/jdtalk/core.d index f3023b2..c0fc376 100644 --- a/lib/jdtalk/core.d +++ b/lib/jdtalk/core.d @@ -177,3 +177,12 @@ string talk(ref dict_t dict) { " "); return output; } + +string talkSalad(ref dict_t dict, int words) { + string[] salad; + for (int i = 0; i < words; i++) { + string[] wordList = [dict.noun, dict.verb, dict.adverb, dict.adjective].choice; + salad ~= word(wordList); + } + return salad.join(" "); +} diff --git a/source/app.d b/source/app.d index 387d19d..a094fcd 100644 --- a/source/app.d +++ b/source/app.d @@ -20,6 +20,7 @@ int main(string[] args) import std.getopt; long i = 0, limit = 0; + int salad = 0; bool exactMatch = false; bool rCase = false; bool hCase = false; @@ -36,6 +37,7 @@ int main(string[] args) "limit|c", format("(default: %d)", limit), &limit, "pattern|p", "Limit output to a root word", &pattern, "exact|e", format("Exact matches only (default: %s)", exactMatch ? "true" : "false"), &exactMatch, + "salad|s", "Produce N random words", &salad, "rcase", format("Randomize case (default: %s)", rCase ? "true" : "false"), &rCase, "hcase", format("Change every other case (default: %s)", hCase ? "true" : "false"), &hCase, "leet", format("1337ify output (default: %s)", haxor ? "true" : "false"), &haxor, @@ -61,7 +63,14 @@ int main(string[] args) } while(true) { - string output = talk(dict); + string output; + + if (salad) { + output = talkSalad(dict, salad); + } + else { + output = talk(dict); + } if (pattern !is null) { if (exactMatch && !hasWord(pattern, output)) { -- cgit