From 5b0938b8901e919d363e6a0843a2c635cb5bbd9f Mon Sep 17 00:00:00 2001 From: mshanemc Date: Tue, 4 Jun 2024 10:01:12 -0500 Subject: [PATCH] feat: warning about alias with spaces --- messages/alias.set.md | 8 +++++++- src/commands/alias/set.ts | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/messages/alias.set.md b/messages/alias.set.md index 507899ff..d4d7497c 100644 --- a/messages/alias.set.md +++ b/messages/alias.set.md @@ -4,7 +4,7 @@ Set one or more aliases on your local computer. # description -Aliases are user-defined short names that make it easier to use the CLI. For example, users often set an alias for a scratch org usernames because they're long and unintuitive. Check the --help of a CLI command to determine where you can use an alias. +Aliases are user-defined short names that make it easier to use the CLI. For example, users often set an alias for a scratch org usernames because they're long and unintuitive. Check the --help of a CLI command to determine where you can use an alias. You can associate an alias with only one value at a time. If you set an alias multiple times, the alias points to the most recent value. Aliases are global; after you set an alias, you can use it in any Salesforce DX project on your computer. @@ -35,3 +35,9 @@ You must provide one or more aliases to set. Use the --help flag to see examples # error.ValueRequired You must provide a value when setting an alias. Use `sf alias unset my-alias-name` to remove existing aliases. + +# warning.spaceAlias + +The alias "%s" includes a space. We recommend aliases without spaces. + +If you decide to keep "%s" to always wrap it in double quotes when using it in any CLI command. diff --git a/src/commands/alias/set.ts b/src/commands/alias/set.ts index 5d1f7851..b69e25be 100644 --- a/src/commands/alias/set.ts +++ b/src/commands/alias/set.ts @@ -34,6 +34,9 @@ export default class AliasSet extends AliasCommand { const results = await Promise.all( Object.entries(parsed).map(async ([alias, value]) => { try { + if (alias.includes(' ')) { + this.warn(messages.getMessage('warning.spaceAlias', [alias, alias])); + } // to support plugin-settings in sfdx, which allowed setting an alias to undefined, when that happens we'll unset the alias // which is what the user wants if (!value) {