diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 85e61179ae..fe2795499c 100644 --- a/src/cli/cli.ts +++ b/src/cli/cli.ts @@ -76,7 +76,7 @@ export const GLOBAL_OPTIONS = { }), env: new EnvironmentOption(), loglevel: new ChoicesParameter({ - alias: "log", + alias: "l", choices: enumToArray(LogLevel), help: "Set logger level.", defaultValue: LogLevel[LogLevel.info], @@ -300,6 +300,11 @@ export class GardenCli { } export async function run(): Promise { - const cli = new GardenCli() - return cli.parse().then(result => shutdown(result.code)) + try { + const cli = new GardenCli() + return cli.parse().then(result => shutdown(result.code)) + } catch (err) { + console.log(err) + shutdown(1) + } } diff --git a/src/cli/helpers.ts b/src/cli/helpers.ts index 8743a1edcd..bcff60e7c6 100644 --- a/src/cli/helpers.ts +++ b/src/cli/helpers.ts @@ -88,8 +88,14 @@ export function falsifyConflictingParams(argv, params: ParameterValues): Fa } // Sywac specific transformers and helpers -export function getOptionSynopsis(key: string, param: Parameter): string { - return param.alias ? `-${param.alias}, --${key}` : `--${key}` +export function getOptionSynopsis(key: string, { alias }: Parameter): string { + if (alias && alias.length > 1) { + throw new InternalError("Option aliases can only be a single character", { + optionName: key, + alias, + }) + } + return alias ? `-${alias}, --${key}` : `--${key}` } export function getArgSynopsis(key: string, param: Parameter) {