-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli
More file actions
43 lines (40 loc) · 1.16 KB
/
cli
File metadata and controls
43 lines (40 loc) · 1.16 KB
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
#!/usr/bin/env node
var rnotify = require('./index');
const path = require('path');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));
const argv = require('yargs') // eslint-disable-line
.usage('Usage: $0 [options] message')
.options({
senders: {
alias: 's',
description: 'Senders configuration file',
default: path.join(process.env.HOME, '/.config/rnotify/senders'),
requiresArg: true,
},
receivers: {
alias: 'r',
description: 'Receivers configuration file',
default: path.join(process.env.HOME, '/.config/rnotify/receivers'),
requiresArg: true,
},
title: {
alias: 't',
description: 'Title',
default: null,
requiresArg: true,
},
})
.demandCommand(1)
.alias('h', 'help')
.help()
.argv;
Promise.join(fs.readFileAsync(argv.senders), fs.readFileAsync(argv.receivers))
.then(function(s) {
const senders = JSON.parse(s[0]);
const receivers = JSON.parse(s[1]);
return rnotify(senders).then(p => {
return p.send(argv.title, argv._[0], receivers);
});
})
.then(function(){});