Is there a way to delete an Apex Class using the Salesforce DX CLI, without using the metadata API and a package.xml file (in the same way you can create an Apex class)?
Answer
You can now use the force:source:delete
option to delete metadata from non-scratch orgs. See the documentation for full usage, but here’s an example:
sfdx force:source:delete -m ApexClass:SomeClassName -r
For scratch orgs, delete the local files, then use the normal push command:
sfdx force:source:push
Original Answer
If, and only if, you’re using scratch orgs, deleting a class in your repo and then using force:source:push should result in a deletion of the components that have been physically removed from the repository. For non-scratch-org deployments, you still need to use the normal force:mdapi:deploy function with a destructiveChanges.xml file.
Attribution
Source : Link , Question Author : salesforce-hacker , Answer Author : sfdcfox