2016-09-24 13:34:05 -04:00
|
|
|
import program from './commander';
|
|
|
|
|
|
|
|
|
|
function logStartupOptions(options) {
|
2016-12-07 15:17:05 -08:00
|
|
|
for (const key in options) {
|
2016-09-24 13:34:05 -04:00
|
|
|
let value = options[key];
|
2018-09-01 13:58:06 -04:00
|
|
|
if (key == 'masterKey') {
|
|
|
|
|
value = '***REDACTED***';
|
2016-09-24 13:34:05 -04:00
|
|
|
}
|
2019-01-27 21:35:33 +01:00
|
|
|
if (key == 'push' && options.verbose != true) {
|
2019-01-27 19:59:15 +01:00
|
|
|
value = '***REDACTED***';
|
|
|
|
|
}
|
2016-09-24 13:34:05 -04:00
|
|
|
if (typeof value === 'object') {
|
2017-10-23 08:43:05 -04:00
|
|
|
try {
|
2018-09-01 13:58:06 -04:00
|
|
|
value = JSON.stringify(value);
|
|
|
|
|
} catch (e) {
|
2017-10-23 08:43:05 -04:00
|
|
|
if (value && value.constructor && value.constructor.name) {
|
|
|
|
|
value = value.constructor.name;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-09-24 13:34:05 -04:00
|
|
|
}
|
2016-11-24 15:47:41 -05:00
|
|
|
/* eslint-disable no-console */
|
2016-09-24 13:34:05 -04:00
|
|
|
console.log(`${key}: ${value}`);
|
2016-11-24 15:47:41 -05:00
|
|
|
/* eslint-enable no-console */
|
2016-09-24 13:34:05 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-01 13:58:06 -04:00
|
|
|
export default function({ definitions, help, usage, start }) {
|
2016-09-24 13:34:05 -04:00
|
|
|
program.loadDefinitions(definitions);
|
|
|
|
|
if (usage) {
|
|
|
|
|
program.usage(usage);
|
|
|
|
|
}
|
|
|
|
|
if (help) {
|
|
|
|
|
program.on('--help', help);
|
|
|
|
|
}
|
|
|
|
|
program.parse(process.argv, process.env);
|
|
|
|
|
|
2016-12-07 15:17:05 -08:00
|
|
|
const options = program.getOptions();
|
2016-09-24 13:34:05 -04:00
|
|
|
start(program, options, function() {
|
|
|
|
|
logStartupOptions(options);
|
|
|
|
|
});
|
2016-12-01 10:24:46 -08:00
|
|
|
}
|