-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
81 lines (68 loc) · 1.78 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
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env node
'use strict';
const inquirer = require('inquirer');
const chalk = require('chalk');
const posResponse = chalk.bold.green;
const negResponse = chalk.redBright;
const resumeData = require('./resume-data.json');
const backPrompt = {
type: 'list',
name: 'answer',
message: 'Go Back or Exit?',
choices: ['Back', 'Exit'],
};
const proceedPrompt = {
type: 'list',
name: 'answer',
message: 'What would you like to know today?',
choices: [...Object.keys(resumeData), 'Exit'],
};
function main() {
console.log('Hello, My name is' + chalk.yellow(' Shubham Bhandari') +
' and this is my resume.');
resumeHandler();
}
function exit() {
console.log(chalk.bold.red('Good Bye! Hope to see you soon.'));
return;
}
function resumeHandler() {
inquirer.prompt(proceedPrompt).then((choice) => {
if (choice.answer == 'Exit') {
exit();
return;
}
console.log(posResponse('-----------------------------------------------' +
'---\n'));
let i = 0;
resumeData[`${choice.answer}`].forEach((data) => {
if (data == '\n') {
i = 0;
console.log();
} else if (i == 0) {
console.log(chalk.bold.cyan('~ ' + data));
i += 1;
} else if (i == 1) {
console.log(chalk.bold.yellow('// ' + data));
i += 1;
} else {
console.log('/ ' + data);
}
});
if (choice.answer == 'About Me') {
console.log('\nAt last: ' + chalk.bold.yellow('Programming' +
' is a SuperPower.'));
}
console.log(negResponse('\n--------------------------------------'
+ '------------'));
inquirer.prompt(backPrompt).then((choice) => {
if (choice.answer == 'Back') {
resumeHandler();
} else {
exit();
return;
}
});
});
}
main();