Skip to content

Commit 5b0938b

Browse files
committed
feat: warning about alias with spaces
1 parent 0782abf commit 5b0938b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

messages/alias.set.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Set one or more aliases on your local computer.
44

55
# description
66

7-
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.
7+
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.
88

99
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.
1010

@@ -35,3 +35,9 @@ You must provide one or more aliases to set. Use the --help flag to see examples
3535
# error.ValueRequired
3636

3737
You must provide a value when setting an alias. Use `sf alias unset my-alias-name` to remove existing aliases.
38+
39+
# warning.spaceAlias
40+
41+
The alias "%s" includes a space. We recommend aliases without spaces.
42+
43+
If you decide to keep "%s" to always wrap it in double quotes when using it in any CLI command.

src/commands/alias/set.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export default class AliasSet extends AliasCommand<AliasResults> {
3434
const results = await Promise.all(
3535
Object.entries(parsed).map(async ([alias, value]) => {
3636
try {
37+
if (alias.includes(' ')) {
38+
this.warn(messages.getMessage('warning.spaceAlias', [alias, alias]));
39+
}
3740
// to support plugin-settings in sfdx, which allowed setting an alias to undefined, when that happens we'll unset the alias
3841
// which is what the user wants
3942
if (!value) {

0 commit comments

Comments
 (0)