message: fix(cli): make positional arguments required and handle errors in serve and bundle manually
diff: @@ -32,7 +32,7 @@ const BUNDLES_DIR = dirname(require.resolve('redoc'));
  /* tslint:disable-next-line */
  YargsParser.command(
  - 'serve [spec]',
  + 'serve <spec>',
  'start the server',
  yargs => {
  yargs.positional('spec', {
  @@ -60,16 +60,22 @@ YargsParser.command(
  return yargs;
  },
  async argv => {
  - await serve(argv.port, argv.spec, {
  + const config = {
  ssr: argv.ssr,
  watch: argv.watch,
  templateFileName: argv.template,
  redocOptions: argv.options || {},
  - });
  + };
  +
  + try {
  + await serve(argv.port, argv.spec, config);
  + } catch (e) {
  + handleError(e);
  + }
  },
  )
  .command(
  - 'bundle [spec]',
  + 'bundle <spec>',
  'bundle spec into zero-dependency HTML-file',
  yargs => {
  yargs.positional('spec', {
  @@ -99,14 +105,20 @@ YargsParser.command(
  return yargs;
  },
  async argv => {
  - await bundle(argv.spec, {
  + const config = {
  ssr: true,
  output: argv.o,
  cdn: argv.cdn,
  title: argv.title,
  templateFileName: argv.template,
  redocOptions: argv.options || {},
  - });
  + };
  +
  + try {
  + await bundle(argv.spec, config);
  + } catch (e) {
  + handleError(e);
  + }
  },
  )
  .demandCommand()
  @@ -117,10 +129,6 @@ YargsParser.command(
  })
  .options('options', {
  describe: 'ReDoc options, use dot notation, e.g. options.nativeScrollbars',
  - })
  - .fail((message, error) => {
  - console.log(error.stack);
  - process.exit(1);
  }).argv;
  async function serve(port: number, pathToSpec: string, options: Options = {}) {
  @@ -296,3 +304,8 @@ function isURL(str: string): boolean {
  function escapeUnicode(str) {
  return str.replace(/\u2028|\u2029/g, m => '\\u202' + (m === '\u2028' ? '8' : '9'));
  }
  +
  +function handleError(error: Error) {
  + console.error(error.stack);
  + process.exit(1);
  +}
  