Linux command
sf 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Log in to a Salesforce org
sf org login web
Create a scratch org
sf org create scratch --definition-file [config/project-scratch-def.json] --alias [my-scratch]
Deploy source
sf project deploy start --target-org [my-org]
Retrieve metadata
sf project retrieve start --target-org [my-org]
Run Apex tests
sf apex run test --target-org [my-org] --code-coverage
Execute a SOQL query
sf data query --query "[SELECT Id, Name FROM Account LIMIT 10]" --target-org [my-org]
Install a package
sf package install --package [04t...] --target-org [my-org]
List all available commands
sf commands
说明
sf (Salesforce CLI) is the official command-line interface for Salesforce development. It manages Salesforce DX projects, creates and manages scratch orgs and sandboxes, deploys and retrieves source code, runs tests, and handles package development. The CLI uses a hierarchical command structure where commands are grouped by topic (org, project, data, apex, package). Most commands accept a --target-org flag to specify which org to operate on, and --json for machine-readable output. Configuration is stored in ~/.sf/ and project-specific settings in sfdx-project.json. Orgs can be aliased for convenience using sf alias set.
参数
- --target-org, -o _alias_
- Specify the target org by username or alias
- --json
- Output results in JSON format
- --help
- Display help for a command
- --version
- Display CLI version
FAQ
What is the sf command used for?
sf (Salesforce CLI) is the official command-line interface for Salesforce development. It manages Salesforce DX projects, creates and manages scratch orgs and sandboxes, deploys and retrieves source code, runs tests, and handles package development. The CLI uses a hierarchical command structure where commands are grouped by topic (org, project, data, apex, package). Most commands accept a --target-org flag to specify which org to operate on, and --json for machine-readable output. Configuration is stored in ~/.sf/ and project-specific settings in sfdx-project.json. Orgs can be aliased for convenience using sf alias set.
How do I run a basic sf example?
Run `sf org login web` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --target-org, -o _alias_ do in sf?
Specify the target org by username or alias