UNPKG

3.48 kBPlain TextView Raw
1#!/usr/bin/env node
2var cli = require('../cli')
3 , path = require('path')
4
5var program = require('commander')
6 .version(require('../package.json').version)
7 .option('-w, --wallet <dir>', 'wallet location (default: ~/.salty)', path.join(process.env.HOME, '.salty'))
8 .option('-F, --force', 'do it anyway')
9
10program
11 .command('init')
12 .description('initialize or update a wallet')
13 .option('-R, --regen', 'regenerate decryption key')
14 .action(cli.init)
15
16program
17 .command('id')
18 .description('output your shareable pubkey string')
19 .alias('pubkey')
20 .action(cli.id)
21
22program
23 .command('import <pubkey|url|file>')
24 .alias('i')
25 .description('import a pubkey')
26 .action(cli.import)
27
28program
29 .command('ls')
30 .alias('l')
31 .description('list imported keys')
32 .action(cli.ls)
33
34program
35 .command('rm <pubkey|email>')
36 .description('remove pubkey')
37 .action(cli.rm)
38
39program
40 .command('encrypt [infile|indir] [outfile]')
41 .alias('e')
42 .description('encrypt a file')
43 .option('-t, --to <email>', 'email address to encrypt for. (must be imported first. default: self)')
44 .option('-m, --message', 'compose a message instead of using [infile] (implies -a)')
45 .option('-s, --sign', 'sign the message to reveal/prove our identity')
46 .option('-H, --header <key: value>', 'add a custom header (repeatable)')
47 .option('-a, --armor', 'output ASCII armor to STDOUT')
48 .option('-g, --gist', 'upload encrypted result as a gist')
49 .option('-F, --force', 'ignore warnings and do it')
50 .option('--no-translate', 'output raw header')
51 .option('-D, --delete', 'delete the original file after encryption')
52 .action(cli.encrypt)
53
54program
55 .command('decrypt <infile|gist> [outfile]')
56 .alias('d')
57 .description('decrypt and verify a file')
58 .option('-s, --sig', 'require a signature')
59 .option('-a, --armor', 'expect ASCII armor, output to STDOUT')
60 .option('-g, --gist', 'download the encrypted input from a gist')
61 .option('-F, --force', 'ignore warnings and do it')
62 .option('--no-translate', 'output raw header')
63 .option('-D, --delete', 'delete the salty file after verification')
64 .action(cli.decrypt)
65
66program
67 .command('sign <infile> [outfile]')
68 .alias('s')
69 .description('create a signature')
70 .option('-H, --header <key: value>', 'add a custom header (repeatable)')
71 .option('-h, --hash <alg>', 'hash algorithm (default: sha256)', String, 'sha256')
72 .option('-a, --armor', 'output ASCII armor to STDOUT')
73 .option('--no-translate', 'output raw header')
74 .option('-F, --force', 'ignore warnings and do it')
75 .action(cli.sign)
76
77program
78 .command('verify <insig> [infile]')
79 .alias('v')
80 .option('-a, --armor', 'expect ASCII armor, output to STDOUT')
81 .option('--no-translate', 'output raw header')
82 .description('verify a signature')
83 .action(cli.verify)
84
85program
86 .command('save [indir] [outfile]')
87 .description('save an encrypted backup of your wallet')
88 .action(cli.save)
89
90program
91 .command('restore [infile] [outdir]')
92 .description('restore your wallet from a backup')
93 .action(cli.restore)
94
95program
96 .command('encode [infile]')
97 .description('output base58-encoded data to STDOUT')
98 .action(cli.encode)
99
100program
101 .command('decode [infile]')
102 .description('output base58-decoded data to STDOUT')
103 .action(cli.decode)
104
105program
106 .command('*')
107 .action(function (infile) {
108 program.outputHelp()
109 process.exit(1)
110 })
111
112program.parse(process.argv)
113
114if (!program.rawArgs[2]) {
115 program.outputHelp()
116 process.exit(1)
117}