| name | sf-apex |
| description | Apex development commands including class and trigger generation, anonymous execution, unit test running, and debug log management. |
sf apex Development
Commands for Apex development.
sf apex generate class
Create Apex class.
sf apex generate class --name MyClass \
--output-dir force-app/main/default/classes
sf apex generate class --name MyClassTest \
--template ApexUnitTest \
--output-dir force-app/main/default/classes
Class Templates
DefaultApexClass (default)
ApexException
ApexUnitTest
sf apex generate trigger
Create Apex trigger.
sf apex generate trigger --name AccountTrigger \
--sobject Account \
--event "before insert,after update" \
--output-dir force-app/main/default/triggers
sf apex run
Execute anonymous Apex.
sf apex run --target-org myOrg --file myScript.apex
echo "System.debug('Hello World');" | sf apex run --target-org myOrg
sf apex run --target-org myOrg
sf apex run test
Run Apex tests.
sf apex run test --target-org myOrg --test-level RunLocalTests
sf apex run test --target-org myOrg --tests MyClassTest
sf apex run test --target-org myOrg \
--test-level RunLocalTests \
--code-coverage
sf apex get test
Get test results.
sf apex get test --target-org myOrg --test-run-id <test-run-id>
sf apex get test --target-org myOrg \
--test-run-id <test-run-id> \
--code-coverage
sf apex log get / list / tail
Debug log management.
sf apex log list --target-org myOrg
sf apex log get --target-org myOrg --log-id <log-id>
sf apex log tail --target-org myOrg --color