diff --git a/docs/reference/commands.md b/docs/reference/commands.md index e0a38bec61..c418d08330 100644 --- a/docs/reference/commands.md +++ b/docs/reference/commands.md @@ -16,7 +16,7 @@ The following option flags can be used with any of the CLI commands: | `--root` | `-r` | string | Override project root directory (defaults to working directory). | `--silent` | `-s` | boolean | Suppress log output. | `--env` | `-e` | string | The environment (and optionally namespace) to work against - | `--loglevel` | `-log` | `error` `warn` `info` `verbose` `debug` `silly` | Set logger level. + | `--loglevel` | `-l` | `error` `warn` `info` `verbose` `debug` `silly` | Set logger level. | `--output` | `-o` | `json` `yaml` | Output command result in specified format (note: disables progress logging). ### garden build diff --git a/src/cli/cli.ts b/src/cli/cli.ts index 85e61179ae..f572a1ab72 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,15 @@ export class GardenCli { } export async function run(): Promise { - const cli = new GardenCli() - return cli.parse().then(result => shutdown(result.code)) + let code + try { + const cli = new GardenCli() + const result = await cli.parse() + code = result.code + } catch (err) { + console.log(err) + code = 1 + } finally { + shutdown(code) + } } 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) {