Skip to content

Commit

Permalink
randomize whoami
Browse files Browse the repository at this point in the history
  • Loading branch information
nasan016 committed Dec 5, 2023
1 parent 7592668 commit 6b30f29
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -38,6 +53,9 @@ const HELPOBJ = {
"'repo'",
"View the Github Repository."
],
["'banner'",
"Display the banner."
],
[
"'clear'",
"Clear the terminal."
Expand Down Expand Up @@ -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("<br>");

WHOAMIOBJ.message[r].forEach((ele, idx) => {
if (idx === WHOAMIOBJ.message[r].length - 1) {
ele += "<span class='command'>who am I?</span>"
}
whoami.push(ele);
})

whoami.push("<br>");
return whoami;
}

console.log(CREATEWHOAMI())
const CREATEHELP = () : string[] => {
const help : string[] = []
help.push("<br>")
Expand All @@ -102,4 +137,3 @@ const CREATEHELP = () : string[] => {
const BANNER = CREATEBANNER()
const DEFAULT = CREATEDEFAULT()
const HELP = CREATEHELP()
console.log(HELP)
3 changes: 3 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ function commandHandler(input : string) {
case 'help':
writeLines(HELP)
break;
case 'whoami':
writeLines(CREATEWHOAMI())
break;
default:
writeLines(DEFAULT)
break;
Expand Down

0 comments on commit 6b30f29

Please sign in to comment.