-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex
executable file
·57 lines (49 loc) · 1.33 KB
/
index
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
#!/usr/bin/env node
var readline = require('readline');
var program = require('commander');
var growl = require('growl');
var Timer = require('./timer');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
program
.version('0.0.1')
.usage('[options]')
.option('-p --pomodoro <n>', 'Length of pomodoro in minutes', parseInt)
.option('-r --rest <n>', 'Length of break in minutes', parseInt)
.parse(process.argv);
var timer = Timer({
pomodoro: program.pomodoro,
rest: program.rest
});
function whatNowPrompt() {
rl.question('What now? (p)omodoro, (b)reak, or (e)xit?', function(answer) {
switch (answer) {
case 'p':
console.log('Pomodoro started');
timer.startPom(program.pomodoro);
break;
case 'b':
console.log('Break started');
timer.startBreak(program.rest);
break;
case 'e':
process.exit();
break;
default:
console.log('Invalid answer, try again');
whatNowPrompt();
}
});
}
timer.on('pomodoro', function() {
growl('Pomodoro finished!');
whatNowPrompt();
});
timer.on('break', function() {
growl('Break finished!');
whatNowPrompt();
});
console.log('Pomodoro started');
timer.startPom(program.pomodoro);