-
Notifications
You must be signed in to change notification settings - Fork 0
/
lockup.js
48 lines (38 loc) · 1.28 KB
/
lockup.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
42
43
44
45
46
47
48
const pkg = require('./package');
const program = require('commander');
const inquirer = require('inquirer');
const ora = require('ora');
const Conf = require('conf');
const { log, br, welcome } = require('./src/util/helpers');
const commands = require('./src/commands')();
welcome(pkg);
try {
const config = new Conf({ cwd: process.cwd(), configName: 'lockup-config' });
program
.version(pkg.version)
.option('-v, --debug', 'output debugging info')
.option('-y, --yes', 'answer yes / default to all questions where possible (will fail on permission issues)');
program
.command('config')
.description('Configre what apps and files to clean')
.action(runCommand('interview', config));
program
.command('clean')
.description('Clean your laptop of all sensitive files and save them to a file to uploaded to cloud storage')
.action(runCommand('clean', config));
program
.command('restore')
.description('Restore sensitive files to your laptop')
.action(runCommand('restore', config));
program.parse(process.argv);
} catch(error) {
if (error.stderr) log(error.stderr);
br();
log(`Error: ${error}`);
log(error.stack);
}
function runCommand(name, config) {
return function runCommandWithArgs(...args) {
return commands[name]({ ora, inquirer, config }, ...args);
}
}