UPDATE June 22, 2019
Salesforce has address this shortcoming in Summer '19 by providing a standard project scaffold with the new Template parameter on the project create command, and then you do use --sourcepath
:
sfdx force:project:create -n MyProject -t standard
cd MyProject
sfdx force:auth:web:login --setdefaultusername
sfdx force:source:retrieve --sourcepath force-app/main/default
tree
.
├── README.md
├── config
│ └── project-scratch-def.json
├── force-app
│ └── main
│ └── default
│ ├── applications
│ ├── aura
│ ├── classes
│ ├── contentassets
│ ├── flexipages
│ ├── layouts
│ ├── lwc
│ ├── objects
│ ├── permissionsets
│ ├── staticresources
│ ├── tabs
│ └── triggers
└── sfdx-project.json
end of update
You don't need --sourcepath
. It looks at where you are pointing and tries to pull items which match what you have there already.
What you do need is a package.xml
file to get your entire metadata database; you might need help getting that file for your particular org.
Instead, you can do the following to get going with Apex or Lightning Component development:
force:project:create -n MyProject
cd MyProject
sfdx force:source:retrieve -m CustomObject
sfdx force:source:retrieve -m ApexClass
sfdx force:source:retrieve -m ApexPage
sfdx force:source:retrieve -m ApexClass
sfdx force:source:retrieve -m AuraDefinitionBundle
sfdx force:source:retrieve -m LightningComponentBundle
or you can use this nifty one-liner:
sfdx force:source:retrieve -m CustomObject,ApexClass,ApexPage,ApexTrigger,LightningComponentBundle,AuraDefinitionBundle
That will populate your source tree, and --sourcepath
will work when it's pointed at one of those folders.