mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-09 06:34:53 +03:00
added support for JSON string for --options cli argument
This commit is contained in:
parent
8632b193b2
commit
2e735d1bff
17
cli/index.ts
17
cli/index.ts
|
@ -64,14 +64,18 @@ YargsParser.command(
|
||||||
return yargs;
|
return yargs;
|
||||||
},
|
},
|
||||||
async argv => {
|
async argv => {
|
||||||
|
const redocOptions = getRedocOptions(argv.options);
|
||||||
|
|
||||||
const config: Options = {
|
const config: Options = {
|
||||||
ssr: argv.ssr as boolean,
|
ssr: argv.ssr as boolean,
|
||||||
watch: argv.watch as boolean,
|
watch: argv.watch as boolean,
|
||||||
templateFileName: argv.template as string,
|
templateFileName: argv.template as string,
|
||||||
templateOptions: argv.templateOptions || {},
|
templateOptions: argv.templateOptions || {},
|
||||||
redocOptions: argv.options || {},
|
redocOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(config);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await serve(argv.port as number, argv.spec as string, config);
|
await serve(argv.port as number, argv.spec as string, config);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -116,6 +120,8 @@ YargsParser.command(
|
||||||
return yargs;
|
return yargs;
|
||||||
},
|
},
|
||||||
async (argv: any) => {
|
async (argv: any) => {
|
||||||
|
const redocOptions = getRedocOptions(argv.options);
|
||||||
|
|
||||||
const config = {
|
const config = {
|
||||||
ssr: true,
|
ssr: true,
|
||||||
output: argv.o as string,
|
output: argv.o as string,
|
||||||
|
@ -124,7 +130,7 @@ YargsParser.command(
|
||||||
disableGoogleFont: argv.disableGoogleFont as boolean,
|
disableGoogleFont: argv.disableGoogleFont as boolean,
|
||||||
templateFileName: argv.template as string,
|
templateFileName: argv.template as string,
|
||||||
templateOptions: argv.templateOptions || {},
|
templateOptions: argv.templateOptions || {},
|
||||||
redocOptions: argv.options || {},
|
redocOptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -353,3 +359,10 @@ function handleError(error: Error) {
|
||||||
console.error(error.stack);
|
console.error(error.stack);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getRedocOptions(options) {
|
||||||
|
return options && typeof options === 'string'
|
||||||
|
? JSON.parse(options) : options
|
||||||
|
? options
|
||||||
|
: {};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user