-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghmsg.js
executable file
·37 lines (31 loc) · 992 Bytes
/
ghmsg.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
#!/usr/bin/env node
'use strict';
const program = require('commander');
const encrypt = require('./lib/encrypt');
const decrypt = require('./lib/decrypt');
const meta = require('./package.json');
program
.version(meta.version);
program
.command('encrypt [user]')
.description('Encrypt message to user using public ssh key')
.option('-m, --message <value>', 'Message to send to user')
.action((user, options) => {
encrypt(user, options.opts(), (err, res) => {
if (err) process.stderr.write(err);
if (res) process.stdout.write(res);
});
});
program
.command('decrypt')
.description('Decrypt message using your private ssh key')
.option('-m, --message <value>', 'Encrypted message to decrypt')
.option('-k, --key [value]', 'Path to private ssh key')
.action((options) => {
decrypt(options.opts(), (err, res) => {
if (err) process.stderr.write(err);
if (res) process.stdout.write(res);
});
});
program
.parse(process.argv);