-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands.js
executable file
·88 lines (78 loc) · 1.83 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
const program = require('commander');
const { prompt } = require('inquirer');
const {
addCustomer,
findCustomer,
updateCustomer,
removeCustomer,
listCustomer
} = require('./index');
// Customer Questions
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 <firstname> <lastname> <phone> <email>')
// .alias('a')
// .description('Add a customer')
// .action((firstname,lastname,phone,email)=>{
// addCustomer({firstname,lastname,phone,email});
// });
// Add a Customer
program
.command('add')
.alias('a')
.description('Add a customer')
.action(()=>{
prompt(questions).then(answers => addCustomer(answers));
})
// Find a Customer
program
.command('find <name>')
.alias('f')
.description('Find a customer')
.action(name => findCustomer(name));
// Update a customer
program
.command('update <_id>')
.alias('u')
.description('Update a customer')
.action((_id)=>{
prompt(questions).then(answers => updateCustomer(_id,answers));
})
// Remove a Customer
program
.command('remove <_id>')
.alias('r')
.description('Remove a customer')
.action(_id => removeCustomer(_id));
// List Customers
program
.command('list')
.alias('l')
.description('List all Customers')
.action(()=> listCustomer());
program.parse(process.argv);