Newer Version Available

This content describes an older version of this product. View Latest

CLI Parameter Resolution Order

Because you can specify parameters for a given CLI command in several ways, it’s important to know the order of parameter resolution.

The CLI resolves command-line parameters 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 parameters and arguments, such as --targetusername or sandboxName=FullSbx.
  • Parameters and options listed in a file specified on the command line. An example is a scratch org definition in a file specified by the --definitionfile parameter of force:org:create. If you indicate a parameter or an argument on the command line that differs from what exists in the definition file, the command line takes precedence.
  • Environment variables, such as SFDX_LOG_LEVEL.
  • Local CLI configuration values, such as defaultusername or defaultdevhubusername. To view the local values, run config:list from your project directory.
  • Global CLI configuration values. To view the global values, run config:list from any directory.

Remember, command-line parameters are at the top of the precedence list. For example, if you set the SFDX_DEFAULTUSERNAME environment variable to myorg@mydomain.com but you specify --targetusername myotherorg@myotherdomain.com when running a command, the default username is myotherorg@myotherdomain.com.

If you specify the --targetusername parameter for a specific CLI command, the CLI command connects to an org with that username. It doesn’t connect to the org previously set using defaultusername.