Chapter 5: Salesforce DX CLI Commands

Hello friends, In this Chapter we will Learn sfdx Command Structure
Sfdx Command Structure
All commands have three parts
$ command -flag arguments
  • Command. The command comes first. This tells the system what actions you want the tool to take.
  • Flag. Flags specify a value that triggers a process or tells the command what other variables to include.
  • Arguments. Arguments tell the which process you want to invoke. Arguments usually follow a flag after a space.
    For example, when creating a new sfdx project, if you want to name your project, you use the -n flag and then add the name of your project as the argument -n MyProject.
namespace:topic:[subtopics]:methodName

Display information about the Org 

sfdx force:org:display --targetusername sfdcSmriti

It will display all the limits

sfdx force:limits:api:display

List of all the Salesforce org that you have connected

sfdx force:org:list

Open Salesforce org using cli Command

sfdx force:org:open

Get to know the information about the source org

sfdx force:source --help

Create new lightning component

sfdx force:lightning:component:create --help

Understand related Parameters

–type=aura|lwc [default: aura] type of the Lightning

-n, –componentname=componentname (required) name of the generated
Lightning component

-d, –outputdir=outputdir [default: .] folder for saving the created files

 sfdx force:lightning:component:create --type lwc -n firstLWC --outputdir force-app/main/default/lwc/

Create Apex Class

sfdx force:apex:class:create --help

-n, –classname=classname (required) name of the generated Apex

-t, –template=ApexException|ApexUnitTest|DefaultApexClass|InboundEmailService [default: DefaultApexClass] template
to use for file creation

-d, –outputdir=outputdir [default: .] folder for saving the
created files

fdx force:apex:class:create -n firsApex -t DefaultApexClass -d force-app/main/default/classes/

Push changes to org

sfdx force:source:push

Pull changes from org

sfdx force:source:pull

Work with non Scratch orgs

sfdx force:mdapi

 

Together we can learn faster 

Join LWC study group on Telegram 

Subscribe to Youtube channel and blog to get latest updates

Reference

Explore Command Structure and Navigation

Did you enjoy this article?
Signup today and receive free updates straight in your inbox.
I agree to have my personal information transfered to MailChimp ( more information )
50% LikesVS
50% Dislikes