-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.js
executable file
·83 lines (72 loc) · 1.8 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
#!/usr/bin/env node
const commander = 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'
}
];
commander.program
.version("1.0.0")
.description('Client Management System');
// commander.program
// .command('add <firstname> <lastname> <phone> <email>')
// .alias('a')
// .description('Add a new customer')
// .action((firstname,lastname,phone,email)=>{
// addCustomer({firstname,lastname,phone,email})
// })
commander.program
.command('add')
.alias('a')
.description('Add a new customer')
.action(()=>{
prompt(questions).then(answers=>addCustomer(answers));
})
commander.program
.command('find <name>')
.alias('f')
.description('Find a customer')
.action((name)=>{
findCustomer(name);
})
commander.program
.command('update <_id>')
.alias('u')
.description('Update a customer')
.action((_id)=>{
prompt(questions).then(answers=>updateCustomer(_id,answers));
})
commander.program
.command('remove <_id>')
.alias('r')
.description('Remove a customer')
.action((_id)=>{
removeCustomer(_id);
})
commander.program
.command('list')
.alias('l')
.description('List all customers')
.action(()=>{
listCustomers();
})
commander.program.parse(process.argv);