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.
- Install Visual Studio Code v1.23 or later
- Install SFDX Command Line Interface
- Install this extension ‘Salesforce CLI Integration for Visual Studio Code‘
- Go through my blogs –
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+`).
Available Salesforce CLI Commands
Authorize or Login to an Org Using the Web-Based Flow
force:auth:web:login —clientid —setdefaultdevhubusername —setalias —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.
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.
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
4.Lists all alias
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 browse, Optional
- -u | –targetusername – username or alias for the target org. Overrides the default target org, Optional
sfdx force:org:open -u sfdcEvangel
sfdx force:org:open –path one/one.app
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.