From 6b30f29db3682a7899a115931ba229813d079947 Mon Sep 17 00:00:00 2001 From: Nathaniel Macapinlac Date: Mon, 4 Dec 2023 20:23:48 -0500 Subject: [PATCH] randomize whoami --- src/commands.ts | 38 ++++++++++++++++++++++++++++++++++++-- src/main.ts | 3 +++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/commands.ts b/src/commands.ts index e7d9118..fef2afa 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -21,7 +21,22 @@ const DEFAULTOBJ = { } const WHOAMIOBJ = { - "message" : "Who am I? A question worth exploring." + "message" : [ + [ + "In the kaleidoscope of existence,", + "I am but a reflection questioning the enigma - " + ], + [ + "Amidst cosmic whispers,", + "I navigate the maze of self-discovery,", + "echoing the eternal refrain - " + ], + [ + "In the symphony of life,", + "I am a note inquiring its own melody,", + "harmonizing with the universal query - ", + ], + ], } const HELPOBJ = { @@ -38,6 +53,9 @@ const HELPOBJ = { "'repo'", "View the Github Repository." ], + ["'banner'", + "Display the banner." + ], [ "'clear'", "Clear the terminal." @@ -80,6 +98,23 @@ const CREATEDEFAULT = () : string[] => { return defaultMsg; } +const CREATEWHOAMI = () : string[] => { + const whoami : string[] = []; + const r = Math.floor(Math.random() * WHOAMIOBJ.message.length); + whoami.push("
"); + + WHOAMIOBJ.message[r].forEach((ele, idx) => { + if (idx === WHOAMIOBJ.message[r].length - 1) { + ele += "who am I?" + } + whoami.push(ele); + }) + + whoami.push("
"); + return whoami; +} + +console.log(CREATEWHOAMI()) const CREATEHELP = () : string[] => { const help : string[] = [] help.push("
") @@ -102,4 +137,3 @@ const CREATEHELP = () : string[] => { const BANNER = CREATEBANNER() const DEFAULT = CREATEDEFAULT() const HELP = CREATEHELP() -console.log(HELP) diff --git a/src/main.ts b/src/main.ts index a2411f2..381c47e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -72,6 +72,9 @@ function commandHandler(input : string) { case 'help': writeLines(HELP) break; + case 'whoami': + writeLines(CREATEWHOAMI()) + break; default: writeLines(DEFAULT) break;