diff --git a/packages/angular/cli/models/command-runner.ts b/packages/angular/cli/models/command-runner.ts index 560e34a7b44c..a44c4f1a0755 100644 --- a/packages/angular/cli/models/command-runner.ts +++ b/packages/angular/cli/models/command-runner.ts @@ -182,9 +182,20 @@ export async function runCommand( return 1; } - const parsedOptions = parser.parseArguments(args, description.options); - Command.setCommandMap(commandMap); - const command = new description.impl({ workspace }, description, logger); - - return await command.validateAndRun(parsedOptions); + try { + const parsedOptions = parser.parseArguments(args, description.options); + Command.setCommandMap(commandMap); + const command = new description.impl({ workspace }, description, logger); + + return await command.validateAndRun(parsedOptions); + } catch (e) { + if (e instanceof parser.ParseArgumentException) { + logger.fatal('Cannot parse arguments. See below for the reasons.'); + logger.fatal(' ' + e.comments.join('\n ')); + + return 1; + } else { + throw e; + } + } } diff --git a/packages/angular/cli/models/parser.ts b/packages/angular/cli/models/parser.ts index baa5ec5f0bb4..91082430d3b6 100644 --- a/packages/angular/cli/models/parser.ts +++ b/packages/angular/cli/models/parser.ts @@ -12,7 +12,7 @@ import { Arguments, Option, OptionType, Value } from './interface'; export class ParseArgumentException extends BaseException { constructor( - comments: string[], + public readonly comments: string[], public readonly parsed: Arguments, public readonly ignored: string[], ) {