-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
39 lines (33 loc) · 1.13 KB
/
app.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
var co = require('co')
var program = require('commander')
var config = require('./config')
var timeEntry = require('./timeEntry')
function run(argv) {
program
.version('0.0.1')
.usage('[ start -d <desc> -p <projectId> || stop [ -i <entryId> | -c ] ]')
.option('start', 'Start a time entry')
.option('-d, --entry-desc <desc>', 'description of the time entry')
.option('-p, --projectId <projectId>', 'project ID of the time entry')
.option('stop', 'Stop a time entry')
.option('-i, --entry-id <entryId>', 'ID of time entry')
.option('-c, --current', 'stop current time entry')
.parse(argv);
co(function* () {
var response = '-none-'
if (program.start) {
response = yield timeEntry.start(
program.entryDesc || config.default.entryDesc,
program.projectId || config.default.projectId)
} else if (program.stop) {
if (program.entryId) {
response = yield timeEntry.stop(program.entryId)
} else if (program.current) {
response = yield timeEntry.stopCurrent()
}
}
console.log('RESPONSE:')
console.log(response)
})()
}
run(process.argv)