Package: sfdc-cli
sfdc-cliexiahuang/sfdc-cliis a sfdc development kit.
It is licensed under theApache License 2.0featureThis is the command line app ofexiahuang/SalesforceXyTools.Integrate withexiahuang/xysfdx, and run in vscode.use python3installinstall from pippip3installsfdc-cliinstall from gitgitclonehttps://github.com/exiahuang/sfdc-cli
python3setup.pyinstallSummarycommanddescriptionsfdc project:initinit sfdc projectsfdc meta:retrieveretrieve metadatasfdc meta:template:apex:createinit apex from tempaltesfdc meta:template:trigger:createinit trigger from tempaltesfdc meta:template:page:createinit page(visualforce) from tempaltesfdc meta:template:component:createinit component(visualforce) from tempaltesfdc meta:newcreate metadata in sfdc serversfdc meta:updateupdate metadata in sfdc serversfdc meta:update:forceforce update metadata in sfdc serversfdc meta:deletedelete metadata in sfdc serversfdc meta:refreshrefresh metadata in sfdc serversfdc meta:attrprint metadata attributesfdc meta:refresh:dirrefresh metadata dir from sfdc serversfdc packagexml:serverbuild all packagexml from serversfdc packagexml:localscan local directory to build package.xmlsfdc apex:executeExecutes anonymous Apex codesfdc apex:test:runrun apex testclasssfdc apex:test:coverageget apex coveragesfdc sobject:listlist sobjectsfdc sobject:fields:descdescribe sobject fieldssfdc sobject:export:xlsxexport sfdc sobject as excel filesfdc sobject:data:createinsert sobject data from json datasfdc sobject:data:updateupdate sobject data from json datasfdc sobject:data:getget sobject data from sfdc serversfdc sobject:data:deletedelete sobject data from sfdc serversfdc data:soql:querysoql querysfdc data:tooling:querytooling querysfdc call:rest:apicall salesforce rest apisfdc coder:snippet:soqlsoql snippet creatorsfdc coder:apex:snippet:insert:data:from:soqlcreate apex code from soql querysfdc coder:apex:snippet:insert:ramdam:datacreate insert sobject code, ramdam datasfdc coder:apex:testclass:generatorgenerator testclass from apex codesfdc coder:apex:page:generatorgenerator VisualForce/Controller/DTO/DAO Code from sobjectsfdc coder:copy:auracopy lightningsfdc coder:permission:buildcreate permission metadatasfdc folder:listlist foldersfdc download:attachmentdownload salesforce attachmentsfdc ant:migration:toolinit Ant Migration ToolUsageprint helpsfdc-husage: sfdc [-h]

sfdc development kit v0.1.0

positional arguments:

    ant:migration:tool  see `ant:migration:tool -h`
    apex:execute        see `apex:execute -h`
    apex:test:coverage  see `apex:test:coverage -h`
    apex:test:run       see `apex:test:run -h`
    call:rest:api       see `call:rest:api -h`
    coder:apex:page:generator
                        see `coder:apex:page:generator -h`
    coder:apex:snippet:insert:data:from:soql
                        see `coder:apex:snippet:insert:data:from:soql -h`
    coder:apex:snippet:insert:ramdam:data
                        see `coder:apex:snippet:insert:ramdam:data -h`
    coder:apex:testclass:generator
                        see `coder:apex:testclass:generator -h`
    coder:copy:aura     see `coder:copy:aura -h`
    coder:permission:build
                        see `coder:permission:build -h`
    coder:permission:list
                        see `coder:permission:list -h`
    coder:snippet:soql  see `coder:snippet:soql -h`
    data:soql:query     see `data:soql:query -h`
    data:tooling:query  see `data:tooling:query -h`
    download:attachment
                        see `download:attachment -h`
    folder:list         see `folder:list -h`
    meta:attr           see `meta:attr -h`
    meta:cache          see `meta:cache -h`
    meta:delete         see `meta:delete -h`
    meta:new            see `meta:new -h`
    meta:refresh        see `meta:refresh -h`
    meta:refresh:aura   see `meta:refresh:aura -h`
    meta:refresh:dir    see `meta:refresh:dir -h`
    meta:retrieve       see `meta:retrieve -h`
    meta:template:apex  see `meta:template:apex -h`
    meta:template:component
                        see `meta:template:component -h`
    meta:template:page  see `meta:template:page -h`
    meta:template:trigger
                        see `meta:template:trigger -h`
    meta:update         see `meta:update -h`
    packagexml:local    see `packagexml:local -h`
    packagexml:server   see `packagexml:server -h`
    project:init        see `project:init -h`
    sobject:data:create
                        see `sobject:data:create -h`
    sobject:data:delete
                        see `sobject:data:delete -h`
    sobject:data:get    see `sobject:data:get -h`
    sobject:data:update
                        see `sobject:data:update -h`
    sobject:export:xlsx
                        see `sobject:export:xlsx -h`
    sobject:fields:desc
                        see `sobject:fields:desc -h`
    sobject:list        see `sobject:list -h`
    tools:json:format   json format
    help                see `help -h`

optional arguments:
  -h, --help            show this help message and exitnew project# for productsfdcproject:init-dproject/sfdc-project1-uusername-ppassword-tsecurity_token-ssrc-vapi_version# for sandbox/stgfullsfdcproject:init-dproject/sfdc-project1-uusername-ppassword-tsecurity_token-ssrc-vapi_version--sandboxcdproject/sfdc-project1metadata retrieve# retrieve zip file of all metadatasfdcmeta:retrieve-p.-dpackage_dir-npackage.zip# retrieve zip file of choice metadata : ApexClass ApexTrigger ApexPagesfdcmeta:retrieve-p.-dpackage_dir-npackage1.zip-mApexClassApexTriggerApexPageApexComponentCustomObject# retrieve metadata and unzip, source path: srcsfdcmeta:retrieve-p.-dpackage_dir-npackage2.zip-mApexClassApexTriggerApexPageAuraDefinitionBundleLightningComponentBundle--unzip--delete_after_unzip


sfdcmeta:retrieve-p.-dpackage_dir-npackage2.zip-mCustomObject--unzip--delete_after_unzip

sfdcmeta:retrieve-p.-dpackage_dir-npackage2.zip-mPermissionSet--unzip--delete_after_unzipmetadata templateinit apex class from templatesfdcmeta:template:apex-nHelloApex--templateApexClass.cls
sfdcmeta:template:apex-nHelloApexBatch--templateBatchApexClass.cls
sfdcmeta:template:apex-nHelloApexTest--templateUnitTestApexClass.cls
sfdcmeta:template:apex-nHelloApexBatchTest--templateBDDUnitTestApexClass.clsinit trigger from templatesfdcmeta:template:trigger-nHelloApexTrigger--sobjectOpportunity--templateApexTrigger.trigger
sfdcmeta:template:trigger-nHelloApexTriggerAllEvents--sobjectOpportunity--templateApexTriggerAllEvents.trigger
sfdcmeta:template:trigger-nHelloApexTriggerBulk--sobjectOpportunity--templateApexTriggerBulk.triggerinit visualforce from templatesfdcmeta:template:page-nHelloApexPage--templateApexPage.page
sfdcmeta:template:page-nHelloHeaderPageBlock--templateHeaderPageBlock.pageinit visualforce componentsfdcmeta:template:component-nHelloCmpmetadata new/update/refresh/deletenew metadatasfdcmeta:new-p.-s./src/classes/HelloApex.cls
sfdcmeta:new-p.-s./src/classes/HelloApexBatch.cls
sfdcmeta:new-p.-s./src/classes/HelloApexTest.cls
sfdcmeta:new-p.-s./src/classes/HelloApexBatchTest.cls
sfdcmeta:new-p.-s./src/pages/HelloApexPage.page
sfdcmeta:new-p.-s./src/components/HelloCmp.component
sfdcmeta:new-p.-s./src/triggers/HelloApexTrigger.trigger--sobjectOpportunity
sfdcmeta:new-p.-s./src/triggers/HelloApexTriggerAllEvents.trigger--sobjectOpportunity
sfdcmeta:new-p.-s./src/triggers/HelloApexTriggerBulk.trigger--sobjectOpportunityupdate metadatasfdcmeta:update-p.-s./src/classes/HelloApex.cls
sfdcmeta:update-p.-s./src/classes/HelloApexBatch.cls
sfdcmeta:update-p.-s./src/classes/HelloApexTest.cls
sfdcmeta:update-p.-s./src/classes/HelloApexBatchTest.cls
sfdcmeta:update-p.-s./src/pages/HelloApexPage.page
sfdcmeta:update-p.-s./src/components/HelloCmp.component
sfdcmeta:update-p.-s./src/triggers/HelloApexTrigger.trigger
sfdcmeta:update-p.-s./src/triggers/HelloApexTriggerAllEvents.trigger
sfdcmeta:update-p.-s./src/triggers/HelloApexTriggerBulk.triggermetadata refreshmetadata refresh by filepath# refresh apex/trigger/page/copmonent/ aura filesfdcmeta:refresh-p.-ssrc/classes/HelloApex.cls
sfdcmeta:refresh-p.-s./src/classes/HelloApex.cls
sfdcmeta:refresh-p.-s./src/classes/HelloApexBatch.cls
sfdcmeta:refresh-p.-s./src/aura/HelloWorld/HelloWorld.cmp
sfdcmeta:refresh-p.-s./src/aura/HelloWorld/HelloWorld.css
sfdcmeta:refresh-p.-s./src/aura/HelloWorldmetadata refresh by directorysupport directorys,read more# refresh directory, examplessfdcmeta:refresh:dir-p.-d./src/classes
sfdcmeta:refresh:dir-p.-d./src/triggers
sfdcmeta:refresh:dir-p.-d./src/components
sfdcmeta:refresh:dir-p.-d./src/pages
sfdcmeta:refresh:dir-p.-d./src/layouts
sfdcmeta:refresh:dir-p.-d./src/lwc
sfdcmeta:refresh:dir-p.-d./src/aura# refresh one aura componetsfdcmeta:refresh:aura-p.-s./src/aura/HelloWorlddelete metadatasfdcmeta:delete-p.-s./src/classes/HelloApex.cls
sfdcmeta:delete-p.-s./src/classes/HelloApexBatch.cls
sfdcmeta:delete-p.-s./src/classes/HelloApexTest.cls
sfdcmeta:delete-p.-s./src/classes/HelloApexBatchTest.cls
sfdcmeta:delete-p.-s./src/pages/HelloApexPage.page
sfdcmeta:delete-p.-s./src/components/HelloCmp.component
sfdcmeta:delete-p.-s./src/triggers/HelloApexTrigger.triggermetadata attributesfdcmeta:attr-p.-s./src/classes/HelloApex.clspackage.xmlbuild from server# build package in current directory, filename package.xmlsfdcpackagexml:server

sfdcpackagexml:server-p.-d.-npackage.xmlbuild from localscan directory and build package.xmlsfdcpackagexml:local--scandir./src--savedir.-npackage.xmlsfdc apexExecutes anonymous Apex code# create a apex codemkdir./tmp/echo"System.debug('hello world');">./tmp/HelloApex.apex# run the apex codesfdcapex:execute-p.-s./tmp/HelloApex.apex# use pipecat./tmp/HelloApex.apex|sfdcapex:execute-p.run apex testclasssfdcapex:test:run-p.-s./src/classes/HelloApexTest.cls
sfdcapex:test:run-p.-s./src/classes/HelloApexBatchTest.clsget coveragesfdcapex:test:coverage-p.-f./log/apex_coverage.logsobjectcreate sobject data# insert a accountecho"{\"Name\":\"exiahuang\"}"|sfdcsobject:data:create-sAccount# use json_data_file to create sobject datasfdcsobject:data:create-sAccount--data$json_data_file_pathget sobject datasfdcsobject:data:get-sAccount--id$account_iddelete sobject datasfdcsobject:data:delete-sAccount--id$account_idupdate sobject data# update sobject data from pipeecho"{\"Phone\":\"080-0000-0000\"}"|sfdcsobject:data:update-sAccount--id$account_id# update sobject data from json filesfdcsobject:data:update-sAccount--id$account_id--data$json_data_file_pathlist sobjectcd$project_dir# print in consolesfdcsobject:list# save as markdown filesfdcsobject:list>log/sobject.mdexport sobject as xlsx filecd$project_dirsfdcsobject:export:xlsx-slog/sobject.xlsxdescribe fieldssfdcsobject:fields:desc-s$sobject_namedata querysoql querysfdcdata:soql:query-s"SELECT id,name from USER limit 10"tooling querysfdcdata:tooling:query-s"SELECT Id,Name FROM ApexClass limit 100"call salesforce rest apiGet method# call /services/data/v45.0/sobjectssfdccall:rest:api-e/services/data/v45.0/sobjects# call /services/data/v45.0/sobjects/Accountsfdccall:rest:api-e/services/data/v45.0/sobjects/Account
sfdccall:rest:api-e/services/data/v45.0/sobjects/Opportunityuse file as paramsecho'{"q": "Select Id, Name From ApexClass Limit 3"}'>tmp/sf_rest_test.json
sfdccall:rest:api-mGET-e/services/data/v45.0/tooling/query--use_params--paramstmp/sf_rest_test.jsonuse pipe to call rest apiexample : query ApexCodeCoverage# example1 : query ApexCodeCoverageecho'{"q": "SELECT Id, ApexTestClassId, TestMethodName, ApexClassorTriggerId, NumLinesCovered, NumLinesUncovered, Coverage FROM ApexCodeCoverage"}'|sfdccall:rest:api-mGET-e/services/data/v45.0/tooling/query--use_params# example1 : query ApexClassecho'{"q": "Select Id, Name From ApexClass Limit 3"}'|sfdccall:rest:api-mGET-e/services/data/v45.0/tooling/query--use_paramscode creatorcreate soql#sfdccoder:snippet:soql-s$sobject_name--custom_field_only--updateable_field_only--include_comment--include_relationship#sfdccoder:snippet:soql-sAccount--custom_field_only--updateable_field_only--include_comment--include_relationshipinsert sobject data code snippet from soqlsfdccoder:apex:snippet:insert:data:from:soql-s$soqlsfdccoder:apex:snippet:insert:data:from:soql-s"SELECT name, firstname, lastname FROM Account LIMIT 2"insert sobject data code snippetsfdccoder:apex:snippet:insert:ramdam:data-s$sobject_name--all_fields
sfdccoder:apex:snippet:insert:ramdam:data-sAccount--all_fieldsgenerator testclass from apexsfdccoder:apex:testclass:generator-f$apex_code_file_pathgenerator VisualForce/Controller/DTO/DAO Code from sobjectsfdccoder:apex:page:generator--sobject$sobject_name--savedirtmp/mycode/src--custom_field_only--include_validatecopy lightningsfdccoder:copy:aura-f$from_lightning_path-t$to_lightning_pathsfdccoder:copy:aura-f/app/project/sfdc-project1/src/aura/HelloWorld-t/app/project/sfdc-project1/src/aura/HelloWorld1create permission metadataretrieve sobject metadata first# retrieve sobject metadatasfdcmeta:retrieve-p.-dpackage_dir-npackage2.zip-mCustomObject--unzip--delete_after_unzip# or use meta:refresh:dirsfdcmeta:refresh:dir-p.-d./src/objectscreate permission from sobject metadata# include sobject permission and all fields permissionsfdccoder:permission:build--sobject_dir./src/objects--savefile./src/permissionsets/dev_permission.permissionset--include_all_sobject_permission# fieldPermissionssfdccoder:permission:build--sobject_dir./src/objects--savefile./src/permissionsets/dev_permission.permissionset--fieldsAccount.custom_field1Account.custom_field2Opportunity.custom_field1list fields from sobject metadata directory# list fieldssfdccoder:permission:list-tfields--sobject_dir./src/objects

sfdccoder:permission:list-tfields--sobject_dir./src/objects|grepAccountlist sobject from sobject metadata directory# list sobject
sfdc coder:permission:list -t sobject --sobject_dir ./src/objectssalesforce folder# report foldersfdcfolder:list-nReportFolder# email foldersfdcfolder:list-nEmailTemplatedownload salesforce attachmentdownload salesforce attachment(ContentVersion):max limit size: 2000default filename template:{Id}_{Title}_v{VersionNumber}.{FileExtension}sfdcdownload:attachment--savedirtmp/download--filename"{Title}_v{VersionNumber}.{FileExtension}"--limit2000Ant Migration Toolinit Ant Migration Toolsfdcant:migration:tool# orsfdcant:migration:tool-p.toolsjson formatcat$json_file_path|sfdctools:json:format

sfdctools:json:format-i$json_file_pathFor developerSet up docker# for windows userdockerrun--rm-it-v%cd%:/app-w=/app-eTZ=Asia/Tokyo--namesfdc-cli_developer_1python:3.8bash# for linux/macdockerrun--rm-it-v`pwd`:/app-w=/app-eTZ=Asia/Tokyo--namesfdc-cli_developer_1python:3.8bash# git clonegitclonehttps://github.com/exiahuang/sfdc-cli# setupcdsfdc-cli
pip3install-rrequirement.dev.txt
python3-msfdc_cli.clialiassfdc="python3 -m sfdc_cli.cli"exportPYTHONPATH="/app/sfdc-cli:$PYTHONPATH"sfdc-h# remove commmandunaliassfdcremove pycache### use findfind.|grep-E"(__pycache__|\.pyc|\.pyo$)"|xargsrm-rf### use py3cleanpy3clean.Run test case.new projectpython3-munittesttests.test_projectinit from templatepython3-munittesttests.test_metadata_templatesfdc metadata api# new apex/trigger/page/component templatepython3-munittesttests.test_metadata_template# metadata api: new metadatapython3-munittesttests.test_metadata_api.MetadataApiNewMetaTestCase.test_metadata_new# metadata api: reload cachepython3-munittesttests.test_metadata_api.MetadataApiNewMetaTestCase.test_metadata_cache# metadata api: update metadatapython3-munittesttests.test_metadata_api.MetadataApiUpdateTestCase.test_metadata_update# metadata api: update aura metadatapython3-munittesttests.test_metadata_api.MetadataApiUpdateTestCase.test_metadata_update_arua# metadata api: refresh metadatapython3-munittesttests.test_metadata_api.MetadataApiRefreshTestCase# metadata api: refresh aura metadatapython3-munittesttests.test_metadata_api.MetadataApiRefreshAuraTestCase# metadata api: print attrpython3-munittesttests.test_metadata_api.MetadataApiAttrTestCase# delete metadatapython3-munittesttests.test_metadata_api.MetadataApiDeleteTestCase# test delete aurapython3-munittesttests.test_metadata_api.MetadataApiDeleteTestCase.test_metadata_delete_arua# run testclasspython3-munittesttests.test_testclass.TestclassTestCase.test_run_test# run retrieve apex coveragepython3-munittesttests.test_testclass.TestclassTestCase.test_retrieve_apex_coverage# retrieve zippython3-munittesttests.test_metadata_api.RetrieveApiTestCase# package xml : retrieve from serverpython3-munittesttests.test_package_xml.PackageXmlTestCase.test_package_xml_from_server# package xml : build from localpython3-munittesttests.test_package_xml.PackageXmlTestCase.test_package_xml_from_dir# open in browserpython3-munittesttests.test_browser.BrowserTestCase.test_open_src
python3-munittesttests.test_browser.BrowserTestCase.test_open_aura# open in browser : open sobjectpython3-munittesttests.test_browser.BrowserTestCase.test_open_account_sobject
python3-munittesttests.test_browser.BrowserTestCase.test_open_opp_sobjectsfdc file attribute# file attr# file attrpython3-munittesttests.test_metadata_api.FileAttrTestCaseresult:{"name":"MyApexController","file_path":"project/sfdc-projcet1/src/classes","file_name":"MyApexController.cls","dir":"classes","p_dir":"src","extension":"cls","metadata_type":"ApexClass","metadata_folder":"classes","metadata_sub_folder":"","is_sfdc_file":true,"is_src":true,"is_lux":false,"is_lux_root":false,"is_lwc":false,"is_lwc_root":false,"lux_type":"","lux_name":"","file_key":"classes/MyApexController.cls"}{"name":"HelloWorld","file_path":"project/sfdc-projcet1/src/aura/HelloWorld","file_name":"HelloWorld.cmp","dir":"HelloWorld","p_dir":"aura","extension":"cmp","metadata_type":"AuraDefinition","metadata_folder":"aura","metadata_sub_folder":"HelloWorld","is_sfdc_file":true,"is_src":false,"is_lux":true,"is_lux_root":false,"is_lwc":false,"is_lwc_root":false,"lux_type":"COMPONENT","lux_name":"HelloWorld","file_key":"aura/HelloWorld/HelloWorld.cmp"}packagepython3setup.pysdist
python3setup.pybdist_wininstpy2exe build windows exepy-3.4-mvenv.py34
.py34\Scripts\activate.bat# python -m pip install --upgrade pippipinstallpy2exesetuptools
pipinstallrequestsXlsxWriter
python-V
pythonsetup.pypy2exeAcknowledgementBasic on OpenSourcexlsxwriter (License: BSD)Simple-Salesforce (License: Apache 2.0)requests (License: Apache 2.0)Apex Template From MavensMate