From 2e735d1bff1f623034f45efb2ba5c2bb33d4af22 Mon Sep 17 00:00:00 2001 From: knidarkness Date: Mon, 30 Sep 2019 12:03:09 +0300 Subject: [PATCH] added support for JSON string for --options cli argument --- cli/index.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 73e3a209..1b48635c 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -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 + : {}; +} \ No newline at end of file