This repository has been archived by the owner on Aug 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
cli.js
68 lines (64 loc) · 2.05 KB
/
cli.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
#!/usr/bin/env node
const app = require('./app');
const argv = require('minimist')(process.argv.slice(2));
// select board ***
let board;
if ('i' in argv) {
board = argv.i;
} else {
board = process.env.TRELLO_BOARD_ID;
}
const cliCommands = [
{// Run the CardRecorder class to add date driven comments to trello cards
flag: 'r',
task: 'CardRecorder',
command(file, tN) {
const CR = new app.CardRecorder(file, board);
CR.run()
.then(() => { console.log(`--${tN} Complete--`); });
}
},
{// Run the Stage Manager class to add lists to a board
flag: 's',
task: 'StageManager',
command(file, tN) {
const SM = new app.StageManager(file, board);
SM.run()
.then(() => { console.log(`--${tN} Complete--`); });
}
},
{// Run the Card Creator class to add cards to a board from a file
flag: 'c',
task: 'Card Creator',
command(file, tN) {
const hasNoOrderFile = (typeof argv.o === 'undefined');
const orders = (argv.o === true || hasNoOrderFile) ? 'data/orders.yaml' : argv.o;
const CC = new app.CardCreator(file, board);
CC.createOrders(orders)
.then(() => { console.log(`--${tN} Complete--`); }); }
},
{// Print out a comment to the command line
// Required Flags: -l list name of what the stage will be called, -d Optional what list to look for number of days
// -f Isostring of from date, -t Isostring of to date -o total days
flag: 'b',
task: 'Build Comment',
command(file) {
const BuildCR = new app.CardRecorder(file, board);
let dateList = argv.l;
if (argv.d) {
dateList = argv.d;
}
BuildCR.utilComment(argv.f, argv.t, dateList, argv.o);
}
}
];
function addCommandPrompt(flag, taskName, callback) {
if (flag in argv) {
console.log(`--Invoke ${taskName}--`);
const file = (argv[flag] === true) ? 'data/stages.yaml' : argv[flag];
callback(file, taskName);
}
}
cliCommands.forEach(command => {
addCommandPrompt(command.flag, command.task, command.command);
});