-
Notifications
You must be signed in to change notification settings - Fork 1
/
commandRunners.js
40 lines (37 loc) · 1.35 KB
/
commandRunners.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
const commandPrompts = require('./commandPrompts.js');
const Panels = require('./actions/Panels');
const MyTickets = require('./actions/MyTickets');
/** SWITCH STATEMENT TO IDENTIFY THE COMMAND TO RUN BASED ON USER INPUT **/
const commandRunner = (command) => {
switch (command) {
case 'Display Panels':
return Panels.displayBoardPanels();
case 'Display Tickets':
return commandPrompts.ticketDisplayCommandPrompt();
case 'Create Ticket':
return commandPrompts.createTicketPrompt();
case 'Edit Ticket':
return commandPrompts.updateTicketPrompt();
case 'Close Ticket':
return commandPrompts.closeTicketPrompt();
default:
console.log('That operation does not exist! Try again!');
commandPrompts.commandPrompt();
}
};
/** SWITCH STATEMENT SPECIFICALLY FOR TICKET DISPLAY OPTIONS **/
const ticketDisplayCommandRunner = (command) => {
switch (command) {
case 'Display My Tickets':
return MyTickets.displayAllMyTickets();
case 'Display Panel Tickets':
return commandPrompts.panelTicketsPrompt();
case 'Display My Panel Tickets':
return commandPrompts.myPanelTicketsPrompt();
default:
console.log('Something went wrong when loading ticket display options!');
commandPrompts.commandPrompt();
}
};
module.exports.commandRunner = commandRunner;
module.exports.ticketDisplayCommandRunner = ticketDisplayCommandRunner;