-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
73 lines (65 loc) · 1.37 KB
/
commands.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
#!usr/bin/env node
const program = require('commander');
const { prompt } = require('inquirer');
const {
addCustomer,
findCustomer,
updateCustomer,
removeCustomer,
listCustomers
} = require('./index');
const questions = [
{
type: 'input',
name: 'firstname',
message: 'Customer First Name'
},
{
type: 'input',
name: 'lastname',
message: 'Customer Last Name'
},
{
type: 'input',
name: 'phone',
message: 'Customer Phone Number'
},
{
type: 'input',
name: 'email',
message: 'Customer Email Address'
}
];
program
.version('1.0.0')
.description('Client Management System')
program
.command('add')
.alias('a')
.description('Add a customer')
.action(() => {
prompt(questions).then(answers => addCustomer(answers));
});
program
.command('find <name>')
.alias('f')
.description('Find a customer')
.action(name => findCustomer(name));
program
.command('update <_id>')
.alias('u')
.description('Update a customer')
.action((_id) => {
prompt(questions).then(answers => updateCustomer(_id, answers));
});
program
.command('remove <_id>')
.alias('r')
.description('Remove a customer')
.action(_id => removeCustomer(_id));
program
.command('list')
.alias('l')
.description('List all customers')
.action(() => listCustomers());
program.parse(process.argv);