Salesforce CLI
The developer multi-tool
About Me
☑ CTO of BrightGen
☑ Salesforce MVP
☑ Certified Technical Architect
☑ Prime Minicomputer - PrimeOS
☑ VAX Minicomputer - VMS
☑ HP 9000 - HP UX (Unix)
☑ IBM RS/6000 - AIX (Unix)
Salesforce CLI
☑ sfdx executable
☑ Local installation
☑ Part of SalesforceDX
☑ One tool to rule them all
Authorisation
☑ Login once
☑ CLI manages all tokens
☑ Authorise through browser :
sfdx force:auth:web:login
☑ Specify existing with -u
sfdx force:org:open -u keir.bowden@sfdx.deploy
Deployment
Structured src and package.xml
Deployment
☑ Wait for complete
sfdx force:mdapi:deploy -d src -w 2
☑ Poll
sfdx force:mdapi:deploy -d src
sfdx force:mdapi:deploy:report -i <job>
Running Tests
☑ All in your namespace
sfdx force:apex:test:run -l RunLocalTests
☑ Specific Tests
sfdx force:apex:test:run -l
RunSpecifiedTests -t ConfigAccessorTest
Retrieving Metadata
Requires package.xml
Retrieving
Metadata
☑ Wait for complete
sfdx force:mdapi:retrieve
-k retrieve/package.xml -r .
☑ Poll
sfdx force:mdapi:retrieve
-k retrieve/package.xml -r . -w 0
sfdx force:mdapi:retrieve:report
-i <jobId> -r .
Destructive Changes
Empty package.xml
destructiveChanges.xml
sfdx force:mdapi:deploy -d destroy
Retrieving
Data
☑ sfdx force:data:soql:query -q <query>
Updating Data ☑ sfdx force:data:record:update -s <type> -i
<id> -v "<field>=<value> <field>=<value>"
Creating
Metadata
☑ Apex Class:
sfdx force:apex:class:create -n <name>
-d <directory>
☑ Lightning Component
sfdx force:lightning:component:create
-n <name> -d <directory>
☑ Visualforce Page
sfdx force:visualforce:page:create
-n <name> -d <directory>
☑ No -u option
Created on local file system only
Scripting
Chain
Commands
1. Deploy Codebase
2. Run Tests
Processing
Output
☑ Reformat
☑ Report Results
☑ Take action
Orchestration
1. Clone git repository
2. Deploy
3. Store commit id
More
Information
☑ Home page : sforce.co/2vyFuuY
☑ Setup guide: sforce.co/2FIDlpS
☑ Command reference : sforce.co/2pdPEAe
☑ Release notes : sforce.co/2DWaWH7
☑ Blog series : bobbuzz.me.uk/2GvVaIb
Questions?

Salesforce CLI