Command Properties
If you extend the base SfCommand
class, you get lots of out-of-the-box functionality to develop highly usable commands. Our command generator (sf dev generate command
) creates a Typescript class for your new command that automatically extends SfCommand
.
Here's a brief overview of the various class properties you can set to alter the behavior of your command. See SfCommand
class and the oclif docs to dig a little deeper. To see many of these properties in action, look at the DeployMetadata
class, which implements the sf project deploy start
core Salesforce CLI command.
summary
- String that briefly describes the purpose of the command. Displayed with the--help | -h
flags.description
- String that provides a more in-depth explanation of the command. Displayed with the--help
flag.examples
- Array of strings that provide examples of how to use the command. Displayed with the--help
flag. Rather than "hard code" the CLI command name in the corresponding messages Markdown file, such assf hello world
, use the string<%= config.bin %> <%= command.id %>
instead. The CLI framework automatically inserts the command.aliases
- Array of strings that describe the different names that this command can be invoked by. You typically use thealiases
property for only backward compatibility when you're changing the name of a command.state
- Set tobeta
if you want your command to warn users that it's still in development.hidden
- Set totrue
if you want to hide your command from users.configurationVariablesSection
-HelpSection
that describes the configuration variables that you can use with this command. Only used for displaying help with the--help
flag.envVariablesSection
-HelpSection
that describes the environment variables that can be used with this command. Only used for displaying help with the--help
flag.errorCodes
-HelpSection
that describes the error codes that the command can return. Only used for displaying help with the--help
flag.requiresProject
- Set totrue
if you want the command to throw an error if the user isn't running the command from inside a Salesforce project directory.enableJsonFlag
- Set tofalse
to disable the--json
flag for your command.