-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (60 loc) · 1.72 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
"use strict";
let inquirer = require("inquirer");
let chalk = require("chalk");
const response = chalk.white;
const title = chalk.bold.green;
let resume = require("./resume.json");
let dividerConstructor = require("./divider.js");
let divider = new dividerConstructor(70, "cyan");
let resumePrompts = {
type: "list",
name: "resumeOptions",
message: "What would you like to know about me?",
choices: [...Object.keys(resume), "Exit"]
};
function main() {
console.log("Hello, my name is Marine. Welcome to my resume!");
resumeHandler();
}
function resumeHandler() {
inquirer.prompt(resumePrompts).then(answer => {
if (answer.resumeOptions == "Exit") {
return;
}
let option = answer.resumeOptions;
divider.printTop();
resume[`${option}`].forEach((info, ind) => {
if (typeof info === "string") {
console.log(divider.containString(` ${info}`, response));
} else {
Object.values(info).forEach((value, ind) => {
if (ind > 1) {
console.log(divider.containString(` ${value}`, response));
} else if (ind === 1) {
console.log(divider.containString(` ${value}`, chalk.cyan.bold));
} else {
console.log(divider.containString(` ${value.padEnd(78)}`, title));
}
});
ind !== resume[`${option}`].length - 1 && divider.printLine();
}
});
divider.printBottom();
inquirer
.prompt({
type: "list",
name: "exitBack",
message: "Go back or Exit?",
choices: ["Back", "Exit"]
})
.then(choice => {
if (choice.exitBack == "Back") {
resumeHandler();
} else {
return;
}
});
});
}
main();