-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcli.js
executable file
·33 lines (27 loc) · 912 Bytes
/
cli.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
#!/usr/bin/env node
const { program } = require('commander');
const showUI = require('./src/UserInterface');
const { encrypt, decrypt } = require('./src/index');
program
.version('3.0.1', '-V, --version')
.usage('[options] <mode> <dir>');
program
.command('encrypt <file>')
.option('-v, --verbose', 'enable verbosity')
.option('-t, --trace', 'enable stacktrace')
.option('-p, --tmp <directory>', 'change temporary directory')
.description('encrypt a file or all files in a directory')
.action(encrypt);
program
.command('decrypt <file>')
.option('-v, --verbose', 'enable verbosity')
.option('-t, --trace', 'enable stacktrace')
.option('-p, --tmp <directory>', 'change temporary directory')
.description('decrypt a file or all files in a directory')
.action(decrypt);
program.action(() => program.help());
if (process.argv.length < 3) {
showUI();
} else {
program.parse();
}