imq-cli
Version:
Command Line Interface for IMQ
51 lines • 2.06 kB
JavaScript
var _a;
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = require("chalk");
const lib_1 = require("../../lib");
let PROGRAM = '';
// noinspection JSUnusedGlobalSymbols
_a = {
command: 'get [option]',
describe: 'Prints value for given option from config. If option is ' +
'not provided, will list all config options',
builder(yargs) {
PROGRAM = yargs.argv.$0;
return yargs
.option('j', {
alias: 'json',
boolean: true,
default: false,
describe: 'Prints config in JSON format (only if ' +
'option is not passed)'
})
.default('option', '')
.describe('option', 'Config option to display value [optional]');
},
handler(argv) {
try {
const config = lib_1.loadConfig();
const options = config && Object.keys(config) || [];
if (!options.length) {
return process.stdout.write(chalk_1.default.bold.yellow('Config is empty. Try to init if first by running:') +
'\n\n $ ' +
chalk_1.default.cyan(`${PROGRAM} config init`) + '\n\n');
}
if (argv.option) {
return process.stdout.write(JSON.stringify(config[argv.option]) + '\n');
}
process.stdout.write(chalk_1.default.bold.green('IMQ CLI Config:') + '\n');
if (argv.json) {
return process.stdout.write(chalk_1.default.cyan(JSON.stringify(config, null, 2)) + '\n');
}
for (let option of options) {
process.stdout.write(chalk_1.default.yellow(`${option}`) + ' = ' +
chalk_1.default.cyan(JSON.stringify(config[option])) + '\n');
}
}
catch (err) {
lib_1.printError(err);
}
}
}, exports.command = _a.command, exports.describe = _a.describe, exports.builder = _a.builder, exports.handler = _a.handler;
//# sourceMappingURL=get.js.map
;