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 | -hflags.description- String that provides a more in-depth explanation of the command. Displayed with the--helpflag.examples- Array of strings that provide examples of how to use the command. Displayed with the--helpflag. 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 thealiasesproperty for only backward compatibility when you're changing the name of a command.state- Set tobetaif you want your command to warn users that it's still in development.hidden- Set totrueif you want to hide your command from users.configurationVariablesSection-HelpSectionthat describes the configuration variables that you can use with this command. Only used for displaying help with the--helpflag.envVariablesSection-HelpSectionthat describes the environment variables that can be used with this command. Only used for displaying help with the--helpflag.errorCodes-HelpSectionthat describes the error codes that the command can return. Only used for displaying help with the--helpflag.requiresProject- Set totrueif you want the command to throw an error if the user isn't running the command from inside a Salesforce project directory.enableJsonFlag- Set tofalseto disable the--jsonflag for your command.