added support for JSON string for --options cli argument

This commit is contained in:
knidarkness 2019-09-30 12:03:09 +03:00
parent 8632b193b2
commit 2e735d1bff

View File

@ -64,14 +64,18 @@ YargsParser.command(
return yargs;
},
async argv => {
const redocOptions = getRedocOptions(argv.options);
const config: Options = {
ssr: argv.ssr as boolean,
watch: argv.watch as boolean,
templateFileName: argv.template as string,
templateOptions: argv.templateOptions || {},
redocOptions: argv.options || {},
redocOptions,
};
console.log(config);
try {
await serve(argv.port as number, argv.spec as string, config);
} catch (e) {
@ -116,6 +120,8 @@ YargsParser.command(
return yargs;
},
async (argv: any) => {
const redocOptions = getRedocOptions(argv.options);
const config = {
ssr: true,
output: argv.o as string,
@ -124,7 +130,7 @@ YargsParser.command(
disableGoogleFont: argv.disableGoogleFont as boolean,
templateFileName: argv.template as string,
templateOptions: argv.templateOptions || {},
redocOptions: argv.options || {},
redocOptions,
};
try {
@ -353,3 +359,10 @@ function handleError(error: Error) {
console.error(error.stack);
process.exit(1);
}
function getRedocOptions(options) {
return options && typeof options === 'string'
? JSON.parse(options) : options
? options
: {};
}