This package contains the base command class for Salesforce CLI, SfdxCommand
. Extend this class for convenient access to common Salesforce CLI parameters, a logger, CLI output formatting, scratch orgs, and Dev Hubs. This class extends @oclif/command and is available within a plug-in generated by Salesforce Plug-In Generator.
Commands that extend SfdxCommand
can only be used with Salesforce CLI version 6.8.2 or later. To check your Salesforce CLI version:
$ sfdx version
sfdx-cli/6.42.0-ae478b3cb8 (darwin-x64) node-v8.9.4
To learn more about the features of the Command Library see the [Salesforce CLI Plug-In Developer Guide](https://developer.salesforce.com/docs/atlas.en-us.sfdxcli_plugins.meta/sfdx_cli_plugins/cli_plugins.htm)_.
If you are interested in contributing, please take a look at the CONTRIBUTING guide.
If you are interested in building this package locally, please take a look at the DEVELOPING doc.
SfdxCommand
.Command
, which SfdxCommand
extends.The configuration of flags for an SfdxCommand class, except for the following:
json
and loglevel
are configured automatically for all SfdxCommand classes.targetusername
is enabled using either SfdxCommand.supportsUsername
or SfdxCommand.requiresUsername
.targetdevhubusername
is enabled using either SfdxCommand.supportsDevhubUsername
or SfdxCommand.requiresDevhubUsername
.Additionally, apiversion
is enabled automatically if any of the static *Username
booleans are set, but may be
configured here explicitly as well if those settings are not required.
public static flagsConfig: FlagsConfig = {
name: flags.string({ char: 'n', required: true, description: 'name of the resource to create' }),
source: flags.directory({ char: 'd', required: true, description: 'path of the source directory to sync' }),
wait: flags.minutes({ description: 'number of minutes to wait for creation' }),
notify: flags.url({ description: 'url to notify upon completion' })
};
A table option configuration type. May be a detailed configuration, or more simply just a string array in the simple cases where table header values are the only desired config option.
Defines a varargs configuration. If set to true, there will be no validation and varargs will not be required. The validator function should throw an error if validation fails.
A flag type for a delimited list of strings with the delimiter defaulting to ,
, e.g., "one,two,three". Accepts
an optional delimiter
string
and/or a custom map
function for converting parsed string
values into
a type T
. Produces a parsed (and possibly mapped) array of type T
where T
defaults to string
if no
custom map
function was provided.
A flag type whose presence indicates a true
boolean value. Produces false when not present.
Declares a flag definition to be one of the builtin types, for automatic configuration.
A flag type for a valid date, e.g., "01-02-2000" or "01/02/2000 01:02:34". Produces a parsed Date
.
A flag type for a valid datetime, e.g., "01-02-2000" or "01/02/2000 01:02:34". Produces a parsed Date
.
A flag type for valid directory paths. Produces a validated string.
See @salesforce/core#sfdc.validatePathDoesNotContainInvalidChars, e.g. "this/is/my/path".
A flag type for valid email addresses. Produces a validated string.
See @salesforce/core#sfdc.validateEmail, e.g., "me@my.org".
A flag type with a fixed enumeration of possible option values. Produces a validated string from the options
list.
A flag type for valid file paths. Produces a validated string.
See @salesforce/core#sfdc.validatePathDoesNotContainInvalidChars, e.g. "this/is/my/path".
A flag type useful for overriding the short char
trigger for emitting CLI help. Emits help and exits the CLI.
A flag type for valid Salesforce IDs. Produces a validated string.
See @salesforce/core#sfdc.validateSalesforceId, e.g., "00Dxxxxxxxxxxxx".
A flag type that accepts basic integer values. For floats, binary, octal, and hex, see flags.number.
Produces an integer number
.
A flag type for a valid Duration
in milliseconds, e.g., "5000".
A flag type for a valid Duration
in minutes, e.g., "2".
A flag type for valid integer or floating point number, e.g., "42". Additionally supports binary, octal, and hex
notation. Produces a parsed number
.
A flag type for custom string processing. Accepts a parse
function that converts a string
value to a type T
.
Produces a type T
.
A flag type for a valid Duration
in seconds, e.g., "5".
A flag type for returning a raw string
value without further preprocessing. Produces a string.
A flag type for a valid url, e.g., "http://www.salesforce.com". Produces a parsed URL
instance.
A flag type for emitting CLI version information. Emits the CLI version and exits the CLI.
A deprecation warning message configuration type. A typical instance can pass
name
,type
, andversion
for a standard message. Alternatively, themessageOverride
can be used as a special case deprecated message.