From 22ac4f6cb414c38e01378582ef848cdba8ddf7d2 Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Thu, 7 Feb 2019 17:01:29 -0800 Subject: [PATCH] feat(cli): add --hot alias for --hot-reload flag --- examples/vote/README.md | 4 ++-- garden-service/src/cli/helpers.ts | 10 +++++----- garden-service/src/commands/deploy.ts | 1 + garden-service/src/commands/dev.ts | 7 +++++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/vote/README.md b/examples/vote/README.md index 6c86f468f5..1c7ee37efc 100644 --- a/examples/vote/README.md +++ b/examples/vote/README.md @@ -42,8 +42,8 @@ In a separate tab, open http://result.local.app.garden. The results there will r Hot-reloading needs to be enabled per service when starting `garden deploy` or `garden dev`: ```sh -garden dev --hot-reload=vote -# OR garden deploy -w --hot-reload=vote +garden dev --hot=vote +# OR garden deploy --hot=vote ``` Then try making a change to one of the source files in the `vote` service, to see it synchronize into the diff --git a/garden-service/src/cli/helpers.ts b/garden-service/src/cli/helpers.ts index fb5f74b828..012377661f 100644 --- a/garden-service/src/cli/helpers.ts +++ b/garden-service/src/cli/helpers.ts @@ -98,12 +98,12 @@ export function falsifyConflictingParams(argv, params: ParameterValues): Fa // Sywac specific transformers and helpers 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}, --${key}` + } else if (alias) { + return `-${alias}, --${key}` + } else { + return `--${key}` } - return alias ? `-${alias}, --${key}` : `--${key}` } export function getArgSynopsis(key: string, param: Parameter) { diff --git a/garden-service/src/commands/deploy.ts b/garden-service/src/commands/deploy.ts index de3358d660..86d08cc456 100644 --- a/garden-service/src/commands/deploy.ts +++ b/garden-service/src/commands/deploy.ts @@ -45,6 +45,7 @@ const deployOpts = { Use comma as a separator to specify multiple services. When this option is used, the command is run in watch mode (i.e. implicitly assumes the --watch/-w flag). `, + alias: "hot", }), } diff --git a/garden-service/src/commands/dev.ts b/garden-service/src/commands/dev.ts index 541bf7e33f..ed815d49e1 100644 --- a/garden-service/src/commands/dev.ts +++ b/garden-service/src/commands/dev.ts @@ -39,7 +39,9 @@ const devOpts = { "hot-reload": new StringsParameter({ help: deline`The name(s) of the service(s) to deploy with hot reloading enabled. Use comma as a separator to specify multiple services. - `}), + `, + alias: "hot", + }), } type Args = typeof devArgs @@ -61,7 +63,8 @@ export class DevCommand extends Command { Examples: garden dev - garden dev --hot-reload=foo-service,bar-service # enable hot reloading for foo-service and bar-service + garden dev --hot-reload=foo-service # enable hot reloading for foo-service + garden dev --hot=foo-service,bar-service # enable hot reloading for foo-service and bar-service ` options = devOpts