-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
41 lines (39 loc) · 1.36 KB
/
index.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
#!/usr/bin/env node
const yargs = require('yargs')
const CONSTANTS = require('./constants.js');
const commands = require('./commands.js')
/* commands */
yargs
.command('encrypt','Encrypt file', function(yargs) {
return yargs
.demand(2)
.option('password', CONSTANTS.YARGS_OPTIONS_ENCRYPT_PASSWORD)
.option('algorithm', CONSTANTS.YARGS_OPTIONS_ENCRYPT_ALOGORITHM)
.usage(CONSTANTS.YARGS_OPTIONS_ENCRYPT_USAGE)
.example(CONSTANTS.YARGS_OPTIONS_ENCRYPT_EXAMPLE_1)
.example(CONSTANTS.YARGS_OPTIONS_ENCRYPT_EXAMPLE_2)
.help()
},commands.encrypt)
.command('decrypt','Decrypt file', function(yargs) {
return yargs
.demand(2)
.option('password', CONSTANTS.YARGS_OPTIONS_DECRYPT_PASSWORD)
.option('algorithm', CONSTANTS.YARGS_OPTIONS_DECRYPT_ALOGORITHM)
.usage(CONSTANTS.YARGS_OPTIONS_DECRYPT_USAGE)
.example(CONSTANTS.YARGS_OPTIONS_DECRYPT_EXAMPLE_1)
.example(CONSTANTS.YARGS_OPTIONS_DECRYPT_EXAMPLE_2)
.help()
},commands.decrypt)
.demand(2)
.usage(CONSTANTS.YARGS_USAGE)
.example(CONSTANTS.YARGS_EXAMPLE)
.demand('password')
.alias('password', 'p')
.nargs('password', 1)
.describe('password', CONSTANTS.YARGS_OPTIONS_PASSWORD)
.alias('algorithm', 'a')
.nargs('algorithm', 1)
.describe('algorithm', CONSTANTS.YARGS_OPTIONS_ALGORITHM)
.choices('algorithm', CONSTANTS.QUESTION_ALGORITHM.choices)
.epilogue(CONSTANTS.EPILOGUE_TEXT)
.argv;