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 order of precedence for parameter resolution is:

  1. Command-line parameters, such as --loglevel, --targetusername, or --targetdevhubusername.
  2. Parameters listed in a file specified by the command line. An example is a scratch org definition in a file specified by the --definitionfile parameter of force:org:create.
  3. Environment variables, such as SFDX_LOG_LEVEL.
  4. Local CLI configuration values, such as defaultusername or defaultdevhubusername. To view the local values, run force:config:list from your project directory.
  5. Global CLI configuration values. To view the global values, run force:config:list from any directory.

For example, if you set the SFDX_LOG_LEVEL environment variable to INFO but specify --loglevel DEBUG for a command, the log level is DEBUG. This behavior happens because command-line parameters are at the top of the precedence list.

If you specify the --targetusername parameter for a specific CLI command, the CLI command connects to an org with that username. It does not connect to an org using the defaultusername, assuming that you set it previously with the force:config:set command.