Skip to content

Conversation

@YutongGu
Copy link
Contributor

Description

This PR adds the ability to override configuration values from the command line without modifying the YAML config file.
This is useful for:

  • Testing different configurations quickly
  • Running multiple instances with slightly different settings
  • Scripting and automation
  • Overriding specific values in containerized environments

Usage

# Override a single field
go-librespot -c device_name=MyDevice

# Override nested fields using dot notation
go-librespot --conf server.address=0.0.0.0 --conf server.port=8080

# Multiple overrides
go-librespot -c device_type=speaker -c bitrate=320 -c credentials.type=interactive

# Mix with other flags
go-librespot --config_dir /custom/path -c zeroconf_enabled=true

Configuration Priority

Overrides are applied after all other configuration sources, giving them the highest priority:

  1. -c/--conf overrides ← highest priority
  2. Other command line flags
  3. YAML config file (config.yaml / config.yml)
  4. Default values ← lowest priority

Changes

  • Added -c/--conf flag using StringArrayVarP to accept multiple override values
  • Parses each override in field=value format
  • Supports nested fields via dot notation (e.g., server.address, credentials.type)
  • Includes validation for malformed overrides (missing =, empty field names)

Error Handling

The following cases produce clear error messages:

  • Missing = separator: invalid config override format: fieldvalue (expected field=value)
  • Empty field name: invalid config override: empty field name in =value

@devgianlu devgianlu merged commit 6563513 into devgianlu:master Dec 24, 2025
8 checks passed
@devgianlu
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants