This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-cli.js
56 lines (48 loc) · 1.87 KB
/
index-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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const meow = require('meow');
const dbMuffler = require('./index');
const DEFAULT_CONFIG_FILE_PATH = './db-muffler.json';
const cli = meow(
`
Usage
$ db-muffler <file_path>
Options
--test, -t Test run which would not overwrite input file
--output, -o Output file where the result will be store. Default value is the input file name
--config, -c Config file where developer can store rules on how to obscure DB data. Default value is ./db-muffler.json
Examples
$ db-muffler ./inputfile.sql
Will use ./db-muffler.json config file and then will run muffler to obscure
data and then output the result in inputfile.sql
$ db-muffler ./inputfile.sql --test
Will use ./db-muffler.json config file and then will run muffler to obscure
data and then output the result in stdout
$ db-muffler ./inputfile.sql -o ./outputfile.sql
Will use ./db-muffler.json config file and then will run muffler to obscure
data and then output the result into outputfile.sql
$ db-muffler ./inputfile.sql -o ./outputfile.sql -c ./config.json
Will use config.json config file and then will run muffler to obscure
data and then output the result into outputfile.sql
`,
{
flags: {
test: {
type: 'boolean',
alias: 't',
default: false,
},
output: {
type: 'string',
alias: 'o',
default: '',
},
config: {
type: 'string',
alias: 'c',
default: DEFAULT_CONFIG_FILE_PATH,
},
},
}
);
dbMuffler(cli.input[0], cli.flags)
.then(outputFileName => console.log(`New SQL file was saved to ${outputFileName}`))
.catch(error => console.error(`DB-Muffler Error: ${error}`));