retrieve Commands

Commands to retrieve artifacts from an environment.

retrieve metadata

Retrieve metadata in source format from an org to your local project.

Description for retrieve metadata

You must run this command from within a project.

This command doesn't support source-tracking. The source you retrieve overwrites the corresponding source files in your local project. This command doesn’t attempt to merge the source from your org with your local source files.

To retrieve multiple metadata components, either use multiple --metadata <name> flags or use a single --metadata flag with multiple names separated by spaces. Enclose names that contain spaces in one set of double quotes. The same syntax applies to --manifest and --source-dir.

Examples for retrieve metadata

Retrieve the source files in a directory:

1sf retrieve metadata --source-dir path/to/source

Retrieve a specific Apex class and the objects whose source is in a directory (both examples are equivalent):

1sf retrieve metadata --source-dir path/to/apex/classes/MyClass.cls path/to/source/objects
1sf retrieve metadata --source-dir path/to/apex/classes/MyClass.cls --source-dir path/to/source/objects

Retrieve all Apex classes:

1sf retrieve metadata --metadata ApexClass

Retrieve a specific Apex class:

1sf retrieve metadata --metadata ApexClass:MyApexClass

Retrieve all custom objects and Apex classes (both examples are equivalent):

1sf retrieve metadata --metadata CustomObject ApexClass
1sf retrieve metadata --metadata CustomObject --metadata ApexClass

Retrieve all metadata components listed in a manifest:

1sf retrieve metadata --manifest path/to/package.xml

Retrieve metadata from a package:

1sf retrieve metadata --package-name MyPackageName

Retrieve metadata from multiple packages, one of which has a space in its name (both examples are equivalent):

1sf retrieve metadata --package-name Package1 "PackageName With Spaces" Package3
1sf retrieve metadata --package-name Package1 --package-name "PackageName With Spaces" --package-name Package3

Usage

sf retrieve metadata
[--json]
[-a API-VERSION]
[-x MANIFEST]
[-m METADATA]
[-n PACKAGE-NAME]
[-d SOURCE-DIR]
[-o TARGET-ORG]
[-w WAIT]

Flags

--json
Optional

Format output as json.

Type: boolean
-a | --api-version API-VERSION
Optional

Target API version for the retrieve.

Use this flag to override the default API version, which is the latest version supported the CLI, with the API version in your package.xml file.

Type: option
-x | --manifest MANIFEST
Optional

File path for the manifest (package.xml) that specifies the components to retrieve.

If you specify this parameter, don’t specify --metadata or --source-dir.

Type: option
-m | --metadata METADATA
Optional

Metadata component names to retrieve.

Type: option
-n | --package-name PACKAGE-NAME
Optional

Package names to retrieve.

Type: option
-d | --source-dir SOURCE-DIR
Optional

File paths for source to retrieve from the org.

The supplied paths can be to a single file (in which case the operation is applied to only one file) or to a folder (in which case the operation is applied to all source files in the directory and its subdirectories).

Type: option
-o | --target-org TARGET-ORG
Optional

Login username or alias for the target org.

Overrides your default org.

Type: option
-w | --wait WAIT
Optional

Number of minutes to wait for the command to complete and display results to the terminal window.

If the command continues to run after the wait period, the CLI returns control of the terminal window to you.

Type: option
Default value: 33