SFDX – Salesforce Command Line Interface (CLI) Commands – Part 1

In this blog, I would like to share with you the available Salesforce CLI Commands. CLI Commands will reduce your effort in creating and configuring the Apex, Visualforce, Lightning components. Refer to my previous blogs for setting up the SFDX with visual studio code IDE.

prerequisites

Run Salesforce CLI Commands

To run the command from Visual Studio Code, open the command palette by pressing Ctrl + Shift + P or Cmd + Shift + P or from the Integrated terminal (Ctrl+Cmd+`).

sfdx_commands
SFDX Commands – on Command Palette
login command sfdx
Integrated Terminal – with Login CLI Command

Available Salesforce CLI Commands

  1. Authorize or Login to an Org Using the Web-Based Flow

force:auth:web:loginclientidsetdefaultdevhubusernamesetalias  —instanceurl <https://test.salesforce.com>

    • setdefaultdevhubusername – set the org to be default developer hub org.  optional parameter
    • setalias –  to set the alias name for the connected org by mapping the session id (only generated on successful login)
    • clientid Consumer key of the connected app, optional parameter
    • instanceurl – Instance Url of the org to be connected,  https://login.salesforce.com be the default instance URL

Use the –setdefaultdevhubusername parameter only when authorizing a Dev Hub org. Do not use it when authorizing to other orgs, such as a sandbox.

More details

2.Logout from connected orgs

force:auth:logout –all | –targetusername  – -noprompt

  • – -all | -a  – Includes all authenticated orgs: for example, Dev Hubs, sandboxes, DE orgs, and expired, deleted, and unknown-status scratch orgs, Optional
  • – -noprompt |-p –  do not prompt for confirmation, Optional
  • – -targetusername | -u  – a username or alias for the target org. Overrides the default target org, Optional

– – all and – -targetusername can’t be used together.

More details.

3.Lists all orgs that the Salesforce CLI has created or authenticated

sfdx force:org:list – -all

  • – -all –Lists all authenticated orgs, including expired, deleted, and unknown-status scratch orgs, Optional
  • – -clean –  Remove all local org authorizations for deleted or expired orgs, Optional
  • -p |- -noprompt – Do not prompt for confirmation, Optional

More details.

4.Lists all alias

sfdx force:alias:list

Lists the aliases that the Salesforce CLI can use for various commands and tasks

5. Open a connected Org or Org component

Opens an org in your browser.

sfdx force:org:open -u <Alias | username> -p <Path to components>

  • -p | –path- Navigation URL path (not including domain), Optional
  • -r | –urlonly  –  Displays a navigation URL but doesn’t launch your browseOptional
  • -u | –targetusername – username or alias for the target org. Overrides the default target org, Optional

Example

sfdx force:org:open -u sfdcEvangel

sfdx force:org:open –path one/one.app

More Details.

In the next blog, I will explain about the commands related to scratch org management.

 

Don’t forget to share the post if you like it & bookmark the blog for future references. If you have any comments or doubts on this post, Please comment on the box.

 

References

https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference.htm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s