forked from signalfx/tracing-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.js
executable file
·60 lines (48 loc) · 1.79 KB
/
client.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
#!/usr/bin/env node
const tracer = require('./deedScheduler/tracer');
// Note that importing other modules should occur after
// importing the tracer to ensure their supported
// dependencies have been auto-instrumented.
const yargs = require('yargs');
const client = require('./deedScheduler/client');
function format(response) {
console.log('++++++++++++++++++++++++++++++++++');
console.log('DeedScheduler Response: \n');
console.log(response);
console.log('++++++++++++++++++++++++++++++++++\n');
}
function printResponse(response) {
response.message ? format(response.message) : format(response);
}
yargs
.usage('Usage: $0 <command> [options]')
.scriptName('deedScheduler')
.command('add <deed> <note> <day>', 'Add a task to deedScheduler.',
{}, (argv) => {
client.addItem(argv.deed, argv.note, argv.day)
.then(printResponse)
.catch(console.error);
})
.command('delete [deed] [day]', 'Delete deed.', {}, (argv) => {
client.deleteDeed(argv.deed, argv.day)
.then(printResponse)
.catch(console.error);
})
.command('list [day]', 'Show deeds list.', {}, (argv) => {
client.listDeeds(argv.day)
.then(printResponse)
.catch(console.error);
})
.command('view <deed> [day] [status]', 'Retrieve task from scheduler.',
{}, (argv) => {
client.viewDeed(argv.deed, argv.day, argv.status)
.then(printResponse)
.catch(console.error);
})
.command('update <deed> <day> <status>', 'Update status of deed (uncompleted - 0, completed - 1).',
{}, (argv) => {
client.updateDeed(argv.deed, argv.day, argv.status)
.then(printResponse)
.catch(console.error);
})
.help().argv;