Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
CLI Parameter Resolution Order
Salesforce CLI resolves command-line flags and arguments, definition files, environment variables, and settings in this order, which means items at the top of the list take precedence over items lower down:
- Command-line flags such as --target-org.
- Options listed in a file specified at the command line. An example is a scratch org definition in a file, which you specify with the --definition-file flag of org create scratch. If you specify a flag at the command line, such as --edition, whose value differs from what exists in the definition file, the command-line flag takes precedence.
- Environment variables, such as SF_TARGET_ORG.
- Local configuration variables, such as target-org or target-dev-hub. To view the local configuration variables, run sf config list from your project directory.
- Global CLI configuration variables. To view the global configuration variables, run sf config list --global from any directory.
Remember, command-line flags are at the top of the precedence list. For example, let’s say you set the SF_TARGET_ORG environment variable to myorg@mydomain.com. If you specify --target-org myotherorg@myotherdomain.com when you run a command, it connects to an org with the myotherorg@myotherdomain.com username.
Similarly, let’s say you set the configuration variable target-org to myorg@mydomain.com. If you specify --target-org myotherorg@myotherdomain.com when you run a command, you connect to an org with the myotherorg@myotherdomain.com username.