Config Command

November 27, 2025 ยท View on GitHub

The config command manages persistent configuration settings for the xRegistry CLI. Use it to set default values, configure registry connections, and customize tool behavior.

Synopsis

xrcg config <subcommand> [options]

Subcommands

SubcommandDescription
listDisplay all configuration settings
get <key>Get a specific configuration value
set <key> <value>Set a configuration value
unset <key>Remove a configuration value
resetReset all configuration to defaults

Configuration File Location

Configuration is stored in a JSON file at a platform-specific location:

PlatformLocation
Linux~/.config/xrcg/config.json
macOS~/Library/Application Support/xrcg/config.json
Windows%APPDATA%\xrcg\config.json

Available Configuration Keys

Default Values

These settings provide default values for generate command options:

KeyDescriptionExample
defaults.project_nameDefault project nameMyProject
defaults.languageDefault target languagejava, cs, py, ts
defaults.styleDefault code stylekafkaproducer
defaults.output_dirDefault output directory./generated

Registry Connection

Settings for connecting to remote xRegistry catalogs:

KeyDescriptionExample
registry.base_urlBase URL for the registry APIhttps://registry.example.com
registry.auth_tokenAuthentication token (Bearer)eyJhbGc...
registry.timeoutHTTP timeout in seconds30

Model Settings

KeyDescriptionExample
model.urlCustom xRegistry model schema URLhttps://example.com/model.json
model.cache_timeoutCache duration in seconds3600

Examples

View All Configuration

xrcg config list

Output:

Configuration (from ~/.config/xrcg/config.json):

defaults:
  language: java
  output_dir: ./generated

registry:
  base_url: https://registry.example.com
  timeout: 30

Export as JSON

xrcg config list --format json

Output:

{
  "defaults": {
    "language": "java",
    "output_dir": "./generated"
  },
  "registry": {
    "base_url": "https://registry.example.com",
    "timeout": 30
  }
}

Get a Specific Value

xrcg config get defaults.language

Output:

java

Set Default Values

# Set default language
xrcg config set defaults.language java

# Set default output directory
xrcg config set defaults.output_dir ./generated

# Set multiple defaults
xrcg config set defaults.project_name MyProject
xrcg config set defaults.style kafkaproducer

Now you can run generate with fewer arguments:

# Before: all options required
xrcg generate --projectname MyProject --language java --style kafkaproducer \
  --definitions ./catalog.json --output ./generated

# After: using defaults
xrcg generate --definitions ./catalog.json

Configure Registry Connection

# Set registry URL
xrcg config set registry.base_url https://registry.example.com

# Set authentication token
xrcg config set registry.auth_token "eyJhbGciOiJIUzI1NiIs..."

# Set timeout
xrcg config set registry.timeout 60

Remove a Setting

# Remove a specific setting
xrcg config unset defaults.language

# Verify it's removed
xrcg config get defaults.language
# Output: (not set)

Reset All Configuration

xrcg config reset

Output:

Configuration reset to defaults.

Configuration Precedence

Command-line arguments always take precedence over configuration file settings:

  1. Command-line arguments (highest priority)
  2. Configuration file (config.json)
  3. Environment variables (where applicable)
  4. Built-in defaults (lowest priority)

Example:

# Config has: defaults.language = java
# This command uses Python despite the config:
xrcg generate --language py --definitions ./catalog.json --output ./out

Environment Variables

Some settings can also be set via environment variables:

Environment VariableEquivalent Config Key
XREGISTRY_MODEL_PATHmodel.url
XREGISTRY_REGISTRY_URLregistry.base_url

Environment variables take precedence over config file but are overridden by CLI arguments.

Security Considerations

Protecting Sensitive Data

The registry.auth_token is stored in plain text. For production use:

  1. Use environment variables for tokens in CI/CD:

    export XREGISTRY_AUTH_TOKEN="..."
    
  2. Use credential helpers (future feature)

  3. Restrict file permissions:

    chmod 600 ~/.config/xrcg/config.json
    

Token Rotation

When rotating tokens:

# Update the token
xrcg config set registry.auth_token "new-token-value"

# Verify connection
xrcg catalog endpoint list

Troubleshooting

Config File Not Found

If you see "Configuration file not found", run any set command to create it:

xrcg config set defaults.language java

Permission Denied

On Unix systems, check file permissions:

ls -la ~/.config/xrcg/config.json
chmod 600 ~/.config/xrcg/config.json

Invalid JSON

If the config file becomes corrupted:

# Reset to defaults
xrcg config reset

# Or manually delete and recreate
rm ~/.config/xrcg/config.json
xrcg config set defaults.language java

See Also