-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.ts
60 lines (49 loc) · 1.62 KB
/
contact.ts
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
#!/usr/bin/env node
import './polyfill';
import * as commander from 'commander';
import * as chalk from 'chalk';
import * as actions from './logic';
import * as inquirer from 'inquirer';
import {questions, getIdQuestions, updateContactQuestions} from './questions';
commander
.version('1.0.0')
.description('Simple contact manager')
commander
.command('addContact')
.alias('a')
.description('Add a contact')
.action(() => {
console.log(chalk.yellow('****Contact Management System****'))
});
inquirer.prompt(questions).then((answers: any) => {
actions.addContact(answers);
});
commander
.command('getContact')
.alias('g')
.description('Get Contact')
.action(() => {
console.log(chalk.yellow('=========*** Contact Management System ***=========='));
inquirer.prompt(getIdQuestions).then((answers: any) => { actions.getContact(answers.id)});
});
commander
.command('updateContact')
.alias('u')
.description('Update contact')
.action(() => {
console.log(chalk.yellow('=========*** Contact Management System ***=========='))
inquirer.prompt(updateContactQuestions).then((answers: any) => actions.updateContact(answers))
});
commander
.command('getContactList')
.alias('l')
.description('Get contact list')
.action(() => {
console.log(chalk.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)