Options
All
  • Public
  • Public/Protected
  • All
Menu

NPM

Description

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.

Usage

Check Your Salesforce CLI Version

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

Features

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)_.

Contributing

If you are interested in contributing, please take a look at the CONTRIBUTING guide.

Development

If you are interested in building this package locally, please take a look at the DEVELOPING doc.

Index

Type aliases

DeprecationDefinition

DeprecationDefinition: object | object

A deprecation warning message configuration type. A typical instance can pass name, type, and version for a standard message. Alternatively, the messageOverride can be used as a special case deprecated message.

FlagsConfig

FlagsConfig: object

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' })
};

Type declaration

TableOptions

TableOptions: Partial<OclifTableOptions> | string[]

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.

VarargsConfig

VarargsConfig: object | boolean

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.

Object literals

Const flags

flags: object

Any

Any: Partial<OclifFlags.IFlag<T>> & SfdxProperties

Array

Array: Option<T[]> & object

BaseBoolean

BaseBoolean: Partial<IBooleanFlag<T>>

Boolean

Bounds

Bounds: object

Type declaration

Builtin

Builtin: object & Partial<Describable>

DateTime

DateTime: Option<Date>

Deprecatable

Deprecatable: object

Type declaration

Describable

Describable: object

Type declaration

Discriminant

Discriminant: object

Type declaration

Discriminated

Discriminated: T & Discriminant

Enum

Enum: EnumFlagOptions<T> & SfdxProperties

Input

Input: OclifFlags.Input<T>

Kind

Kind: keyof object

Milliseconds

Milliseconds: Option<Duration> & Bounds<Duration | number>

Minutes

Minutes: Option<Duration> & Bounds<Duration | number>

Number

Number: Option<number> & NumericBounds

NumericBounds

NumericBounds: Bounds<number>

Option

Option: Partial<IOptionFlag<Optional<T>>> & SfdxProperties

Output

Output: OclifFlags.Output

Seconds

Seconds: Option<Duration> & Bounds<Duration | number>

SfdxProperties

SfdxProperties: Describable & Deprecatable

String

String: Option<string>

Url

Url: Option<URL>

array

array: buildArray = buildArray

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.

boolean

boolean: buildBoolean = buildBoolean

A flag type whose presence indicates a true boolean value. Produces false when not present.

builtin

builtin: buildBuiltin = buildBuiltin

Declares a flag definition to be one of the builtin types, for automatic configuration.

date

date: buildDate = buildDate

A flag type for a valid date, e.g., "01-02-2000" or "01/02/2000 01:02:34". Produces a parsed Date.

datetime

datetime: buildDatetime = buildDatetime

A flag type for a valid datetime, e.g., "01-02-2000" or "01/02/2000 01:02:34". Produces a parsed Date.

directory

directory: buildDirectory = buildDirectory

A flag type for valid directory paths. Produces a validated string.

See @salesforce/core#sfdc.validatePathDoesNotContainInvalidChars, e.g. "this/is/my/path".

email

email: buildEmail = buildEmail

A flag type for valid email addresses. Produces a validated string.

See @salesforce/core#sfdc.validateEmail, e.g., "me@my.org".

enum

enum: buildEnum = buildEnum

A flag type with a fixed enumeration of possible option values. Produces a validated string from the options list.

filepath

filepath: buildFilepath = buildFilepath

A flag type for valid file paths. Produces a validated string.

See @salesforce/core#sfdc.validatePathDoesNotContainInvalidChars, e.g. "this/is/my/path".

help

help: buildHelp = buildHelp

A flag type useful for overriding the short char trigger for emitting CLI help. Emits help and exits the CLI.

id

id: buildId = buildId

A flag type for valid Salesforce IDs. Produces a validated string.

See @salesforce/core#sfdc.validateSalesforceId, e.g., "00Dxxxxxxxxxxxx".

integer

integer: buildInteger = buildInteger

A flag type that accepts basic integer values. For floats, binary, octal, and hex, see flags.number. Produces an integer number.

milliseconds

milliseconds: buildMilliseconds = buildMilliseconds

A flag type for a valid Duration in milliseconds, e.g., "5000".

minutes

minutes: buildMinutes = buildMinutes

A flag type for a valid Duration in minutes, e.g., "2".

number

number: buildNumber = buildNumber

A flag type for valid integer or floating point number, e.g., "42". Additionally supports binary, octal, and hex notation. Produces a parsed number.

option

option: buildOption = buildOption

A flag type for custom string processing. Accepts a parse function that converts a string value to a type T. Produces a type T.

seconds

seconds: buildSeconds = buildSeconds

A flag type for a valid Duration in seconds, e.g., "5".

string

string: buildString = buildString

A flag type for returning a raw string value without further preprocessing. Produces a string.

url

url: buildUrl = buildUrl

A flag type for a valid url, e.g., "http://www.salesforce.com". Produces a parsed URL instance.

version

version: buildVersion = buildVersion

A flag type for emitting CLI version information. Emits the CLI version and exits the CLI.