1 | const program = require("commander");
|
2 |
|
3 | const helpers = require("../dist");
|
4 |
|
5 | program
|
6 | .option("-a, --api-key <apiKey>", "Config api key of postman")
|
7 | .parse(process.argv);
|
8 |
|
9 | const stdout = console.log.bind(console);
|
10 |
|
11 | function config(opts) {
|
12 | const config = {};
|
13 | let empty = true;
|
14 | for (let k in opts) {
|
15 | if (opts[k]) {
|
16 | empty = false;
|
17 | config[k] = opts[k];
|
18 | }
|
19 | }
|
20 |
|
21 | if (empty) {
|
22 | stdout(JSON.stringify(helpers.getConfig(), null, 2));
|
23 | } else {
|
24 | helpers.writeConfig(config);
|
25 | }
|
26 |
|
27 | process.exit(0);
|
28 | }
|
29 |
|
30 | config(program.opts());
|