xg env template
xg env template
Section titled “xg env template”Generates a blank environment configuration template as a JSON file. The template contains a single sample D365EnvironmentConfiguration entry pre-filled with placeholder values, along with an empty ActiveEnvironmentFriendlyName field. You can edit the template manually and feed it directly to xg env import to bootstrap one or more environment entries.
License requirement: This sub-command requires an active Pro (or higher) subscription. Running it without a valid Pro licence returns a non-zero exit code.
Synopsis
Section titled “Synopsis”xg env template --output <FILE_PATH>Description
Section titled “Description”xg env template produces a JSON scaffold that mirrors the structure expected by xg env import. The generated file contains:
- A single
Environmentsarray with one placeholder entry. - Key fields (
FriendlyName,EnvironmentUrl,AuthenticationMethod,ClientId,MetadataCacheLifecycle) set to sensible default values. ClientSecretis intentionally omitted from the output (the field is[JsonIgnore]-decorated in the CLI source). Supply the secret interactively when runningxg env import, or add it to the JSON manually before importing in a secure, non-version-controlled location.ActiveEnvironmentFriendlyNameset tonull— activate an environment after import withxg env activateor via the interactivexg env addwizard.
If the parent directory of the output path does not exist, the CLI creates it automatically.
Output format
Section titled “Output format”The generated file is indented JSON (not YAML). Null fields are omitted (DefaultIgnoreCondition = WhenWritingNull).
Example of generated content:
{ "Environments": [ { "FriendlyName": "MY-ENV-NAME", "EnvironmentUrl": "https://myorg.crm.dynamics.com", "AuthenticationMethod": "ClientSecret", "ClientId": "YOUR_CLIENT_ID_GUID", "MetadataCacheLifecycle": "7.00:00:00" } ]}Options
Section titled “Options”| Flag | Type | Default | Description |
|---|---|---|---|
-o / --output <FILE_PATH> | string | (required) | Destination path for the generated JSON template. If the directory does not exist, the CLI creates it. The command fails with exit code 1 if this flag is omitted or empty. |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Template written successfully. |
1 | Missing or empty --output path; I/O error writing the file; licence insufficient (non-Pro). |
Examples
Section titled “Examples”Generate a template to the current directory
Section titled “Generate a template to the current directory”xg env template --output ./env-template.jsonGenerate a template to a specific path (creating the directory if needed)
Section titled “Generate a template to a specific path (creating the directory if needed)”xg env template --output ~/.config/xrmghost/environments/template.jsonGenerate a template and immediately import it (after manual edits)
Section titled “Generate a template and immediately import it (after manual edits)”# 1. Create the templatexg env template --output ./my-envs.json
# 2. Edit my-envs.json: replace placeholder values with your real environment details# (FriendlyName, EnvironmentUrl, ClientId, etc.)
# 3. Import the edited file — the CLI will prompt for ClientSecret interactivelyxg env import ./my-envs.jsonSee Also
Section titled “See Also”xg env import— Import environment configurations from a JSON file (accepts the format produced by this command).xg env add— Interactive wizard to add a single environment without editing a JSON file.- CLI Reference landing page — Full list of available commands and reference structure.
- CLI Overview — Introduction to the
xgCLI and its command groups.