forked from getmoro/moro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
moro.js
executable file
·98 lines (92 loc) · 2.05 KB
/
moro.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
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env node
// packages
const prog = require('caporal')
// ours
// constants
const VERSION = require('./package.json').version
const COMMAND_DESCRIPTIONS = require('./constants.json').TEXT.commands
// importing all the commands
const {
nextUndoneAction,
setStart,
setEnd,
setBreak,
report,
clearData,
setConfig,
addNote
} = require('./commands.js')
// All the possible commands and arguments:
// moro
// moro hi 08:23
// moro bye
// moro bye 17:30
// moro break 32
// moro break -32
// moro report
// moro report --all
// moro config --day 8.5
// moro config --break 45
// moro clear --yes
prog
// default command
.version(VERSION)
.description(COMMAND_DESCRIPTIONS.default)
.action(nextUndoneAction)
//
// ////////////////////
// hi
//
.command('hi', COMMAND_DESCRIPTIONS.hi)
.alias('h')
.argument('<start>', COMMAND_DESCRIPTIONS.hiStart, /^\d\d:\d\d$/)
.action(setStart)
//
// ////////////////////
// bye
//
.command('bye', COMMAND_DESCRIPTIONS.bye)
.alias('b')
.argument('<end>', COMMAND_DESCRIPTIONS.byeEnd, /^\d\d:\d\d$/)
.action(setEnd)
//
// ////////////////////
// break
//
.command('break', COMMAND_DESCRIPTIONS.break)
.argument('<duration>', COMMAND_DESCRIPTIONS.breakDuration, /^[\d]+$/)
.action(setBreak)
//
// ////////////////////
// // report
//
.command('report', COMMAND_DESCRIPTIONS.report)
.alias('r')
.option('--all', COMMAND_DESCRIPTIONS.reportAll)
.action(report)
//
// ////////////////////
// clear
//
.command('clear', '')
.option('--yes', 'you need to confirm before I remove everything')
.action(clearData)
//
// ////////////////////
// config
//
.command('config', COMMAND_DESCRIPTIONS.config)
.alias('c')
.option('--day <duration>', COMMAND_DESCRIPTIONS.configDay, prog.FLOAT)
.option('--break <duration>', COMMAND_DESCRIPTIONS.breakDuration, prog.INT)
.action(setConfig)
//
// ////////////////////
// note
//
.command('note', COMMAND_DESCRIPTIONS.note)
.alias('n')
.argument('[note...]', COMMAND_DESCRIPTIONS.noteNote)
.action(addNote)
// let it begin!
prog.parse(process.argv)