CLI Parameter Resolution Order
Because you can specify parameters for a given Salesforce CLI command in several ways, it’s important to know the order of resolution.
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-fileflag oforg 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-orgortarget-dev-hub. To view the local configuration variables, runsf config listfrom your project directory. - Global CLI configuration variables. To view the global configuration variables, run
sf config list --globalfrom 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.
See Also