-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
64 lines (58 loc) · 1.65 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(() => {
const meow = require('meow');
const {
promisify
} = require('util');
const fs = require('fs');
const {
Processor
} = require('./src/processor/index');
const isAccessible = promisify(fs.access);
const cli = meow(`
Usage
$ scan <filePath>
Options
--query, -q Disable Db Modification (true default)
Examples
$ scan .\\img-path --query
`, {
flags: {
query: {
type: 'boolean',
alias: 'r',
default: true
},
pretty: {
type: 'boolean',
alias: 'p',
default: true
}
}
});
let cmd = cli.input[0] || '';
let filePath = cli.input[1] || '';
let flags = cli.flags;
if (cli.input.length > 0) {
switch (cmd) {
case 'scan':
isAccessible(filePath).then((isUnavailable) => {
if (!isUnavailable) {
let processor = Processor.create({
filePath: filePath,
queryingEnabled: !!flags.q || flags.query,
isPretty: !!flags.p || flags.pretty
});
processor.execute((err) => {
if (err) console.log(err);
});
}
});
break;
default:
console.log('Command not found');
break;
}
} else {
console.log('Try running --help for more info');
}
})();