-
Notifications
You must be signed in to change notification settings - Fork 11
/
contact.js
57 lines (57 loc) · 2.08 KB
/
contact.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
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("./polyfills");
var commander = require("commander");
var inquirer = require("inquirer");
var chalk_1 = require("chalk");
var actions = require("./logic");
var questions_1 = require("./questions");
commander
.version('1.0.0')
.description('Contact Management System');
commander
.command('addContact')
.alias('a')
.description('Add a contact')
.action(function () {
console.log(chalk_1.default.yellow('=========*** Contact Management System ***=========='));
inquirer.prompt(questions_1.questions).then(function (answers) { return actions.addContact(answers); });
});
commander
.command('getContact')
.alias('g')
.description('Get Contact')
.action(function () {
console.log(chalk_1.default.yellow('=========*** Contact Management System ***=========='));
inquirer.prompt(questions_1.getIdQuestions).then(function (answers) { return actions.getContact(answers.id); });
});
commander
.command('updateContact')
.alias('u')
.description('Update Contact')
.action(function () {
console.log(chalk_1.default.yellow('=========*** Contact Management System ***=========='));
inquirer.prompt(questions_1.updateContactQuestions).then(function (answers) { return actions.updateContact(answers); });
});
commander
.command('deleteContact')
.alias('d')
.description('Delete a contact')
.action(function () {
console.log(chalk_1.default.yellow('=========*** Contact Management System ***=========='));
inquirer.prompt(questions_1.getIdQuestions).then(function (answers) { return actions.deleteContact(answers.id); });
});
commander
.command('getContactList')
.alias('l')
.description('Get Contact List')
.action(function () {
console.log(chalk_1.default.yellow('=========*** Contact Management System ***=========='));
actions.getContactList();
});
if (!process.argv.slice(2).length /* || !/[arudl]/.test(process.argv.slice(2))*/) {
commander.outputHelp();
process.exit();
}
commander.parse(process.argv);