-
Notifications
You must be signed in to change notification settings - Fork 25
Home
NOTE: This feature is a Beta Service. Customers may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.
Want to dive right in and read the rest of the documentation later? Here you go:
- Install sf.
- Run Through the Dreamhouse Example.
- Check the Issues tab for known issues with
sf
, and to enter one yourself if necessary.
sf
is a new Salesforce CLI executable that provides a single set of commands for all Salesforce development. The new executable, sf
, is bundled with Salesforce CLI so you can keep using the sfdx
commands you know and love. But you can also start using the new sf
commands that are designed for cross-cloud app development and deployment. The two executables are fully aware of each other, so, for example, you can start using sf
commands on orgs you've already created or authorized with sfdx
commands.
sf
is similar to sfdx
in that it's a command-line interface that simplifies Salesforce development and build automation. But it also includes some key new features and design changes.
-
The
sf
command hierarchy reflects a typical developer's workflow rather than Salesforce brands, products, or features.For example, the top-level topics include configuring the CLI (
sf config
), logging into environments (sf login
), deploying and retrieving (sf deploy
andsf retrieve
), and managing environments (sf env
). Later sf releases will add top-level topics for creating scaffolded artifacts, running code, testing, and managing data.As
sf
grows and embraces other Salesforce clouds, it will include their commands in this workflow-focused hierarchy instead of each product having its own command hierarchy. Becausesf
creates consistency across all these commands, it's easier and more intuitive to use, even when developing on a new cloud. -
sf
provides interactive commands that actively prompt you for required information rather than passively accepting flag values. Now you don't have to remember all the flag names or which are required, which in turn reduces errors. For example,sf deploy
prompts you for the deployment environment and artifacts, level of testing, and so on.Each interactive command has an environment-specific command for use in automated scripts. For example,
sf deploy metadata
has flags to specify the org you're deploying to, the metadata location, and so on. -
Improved
--help
output:- The short flag descriptions are grouped into logical groups for easier reading, which is especially useful when a command has many flags.
- All examples have brief explanations.
- The long flag descriptions are displayed at the end of the
--help
output. Insfdx
, the long flag descriptions don’t display in the--help
output at all, they’re documented only in the Salesforce CLI Command Reference.
-
The command output has been improved for readability and standardized.
-
The commands to deploy and retrieve org metadata (
sf deploy|retrieve metadata
) don't yet include source-tracking functionality. If you want to use source-tracking in scratch orgs or sandboxes, keep using thesfdx force:source:push|pull
commands for now. -
sf
uses spaces between topics, commands, and subcommands rather than colons. For example, thesf
command to get a configuration variable issf config get
; insfdx
it'ssfdx config:get
. -
Where appropriate, we've renamed
sfdx
flags insf
to include dashes in its name for better readability. For example,--apiversion
insfdx
is now--api-version
insf
. -
In
sf
, you have two ways to use flags that take multiple values:- Specify the flag multiple times, with each flag taking a different single value. For example:
sf deploy metadata --metadata ApexClass \ --metadata CustomObject \ --metadata AnotherCustomObject
- Specify the flag one time, but separate all the values with a space:
sf deploy metadata --metadata ApexClass CustomObject AnotherCustomObject
- In sfdx you specify the flag one time and separate the values with commas:
sfdx force:source:deploy --metadata ApexClass,CustomObject,AnotherCustomObject
-
While equivalent
sf
andsfdx
commands, such assf config set
andsfdx config:set
, are interoperable and aware of each other, they produce different JSON output.
A quick word about these sf terms:
-
Environments: A general term for the thing you use the CLI to interact with, such as the org to which you deploy metadata. For beta, we support only environments that are Salesforce orgs. Future releases will include environments to which you deploy Salesforce Functions.
Commands for managing environments are grouped under the
sf env
topic, such assf env list
, which lists all the environments you've created or logged into. -
Logging in: In
sf
you log into an environment, which authorizes the CLI to run other commands that interact with that environment. Insfdx
we use the term authorize. -
Flags: In
sf
we consistently use the term flag in the documentation, such as the--json
flag of a command. Insfdx
we use the terms parameter, flag, and option in the documentation, sometimes interchangeably. -
Configuration variables: In
sf
, you use configuration variables to configure aspects of the CLI. Insfdx
we call them configuration values.
The sf
and sfdx
commands play nicely together.
In this beta release, the only environments you can interact with are Salesforce orgs (scratch orgs, Dev Hubs, production orgs, sandboxes, and so on). Org authorizations are interoperable between sf
and sfdx
.
In practice this means that when you create a scratch org, authorize an org, or log out of an org with sfdx
, the sf
commands respect these actions. The reverse is also true: if you log in or out of an environment in sf
, the sfdx
commands respect it.
For example, let's say you create a scratch org with sfdx force:org:create
. When you run sf env list
in the same project, the new scratch org is displayed.
Similarly, if you log into an org with sf login org,
then run sfdx force:org:list
, the org you logged into is displayed.
Aliases are interoperable between sf
and sfdx
.
For example, if you run sfdx force:org:create --setalias MyScratchOrg
, you can use this alias in sf
, such as sf env open --target-env MyScratchOrg
.
Similarly, if you run sf login org --alias MyDevHub
, you can use this alias in sfdx
, such as sfdx force:org:open --targetusername MyDevHub
.
Configuration variables are interoperable between sf
and sfdx
. But we've made two important name changes:
-
defaultusername
(sfdx
) has been renamedtarget-org
insf
. -
defaultdevhubusername
(sfdx
) has been renamedtarget-dev-hub
insf
.
Other than the preceding two configuration variables, the rest of the sfdx
variables have the same name and work the same way in sf
.
Let's run through a few use cases to see how the interoperability works, using target-org
and defaultusername
as examples. The same behavior applies to target-dev-hub
and defaultdevhubusername
, and the rest.
Here's the general rule: if you set target-org
to a value, then defaultusername
is also automatically set to the same value. And vice versa.
Action: Use this sfdx
command to create a scratch org:
sfdx force:org:create --setdefaultusername -f config/project-scratch-def.json --setalias my-scratch-org
Then run sfdx config:list
and sf config list
.
Result: Both defaultusername
and target-org
are set to my-scratch-org
.
Action: Use this sf
command to set the target-org
configuration variable to an org with alias uat-testing-org
:
sf config set target-org=uat-testing-org
Then run sfdx config:list
and sf config list
.
Result: Both defaultusername
and target-org
are set to uat-testing-org
.
Action: Use this sfdx
command to set the defaultusername
configuration variable to an org with alias production-org
:
sfdx config:set defaultusername=production-org
Then run sfdx config:list
and sf config list
.
Result: Both defaultusername
and target-org
are set to production-org
.
Action: Use this sf
command to set defaultusername
:
sf config set defaultusername=other-org
Result: Error, because you can't use sf
commands to directly set defaultusername
.
Action: Use this sfdx
command to set target-org
:
sfdx config:set target-org=other-org
Result: Error, because you can't use sfdx
commands to directly set target-org
.
To recap, this table lists all available configuration variables in both sf and sfdx.
sf Configuration Variable | Equivalent sfdx Configuration Value |
---|---|
apiVersion |
apiVersion |
disableTelemetry |
disableTelemetry |
instanceUrl |
instanceUrl |
maxQueryLimit |
maxQueryLimit |
restDeploy |
restDeploy |
target-dev-hub |
defaultdevhubusername |
target-org |
defaultusername |
If you've already installed Salesforce CLI and are currently using sfdx
commands, update to the latest version of sfdx
and you automatically get the sf
executable:
sfdx update
If you aren't currently using sfdx
, install sf
using operating system-specific installers such as *.pkg on macOS. We've updated all Salesforce CLI installers to include both the sfdx
and sf
executables. See Install Salesforce CLI for details. After you install, run sfdx update
to start using sf
.
To install using npm, run this command:
npm install @salesforce/cli --global
© Copyright 2024 Salesforce.com, inc. All rights reserved. Various trademarks held by their respective owners.
- Quick Intro to Developing sf Plugins
- Get Started: Create Your First Plugin
- Design Guidelines
- Code Your Plugin
- Debug Your Plugin
- Write Useful Messages
- Test Your Plugin
- Maintain Your Plugin
- Integrate Your Plugin With the Doctor Command
- Migrate Plugins Built for sfdx
- Conceptual Overview of Salesforce CLI