CLI Reference

generate

The core command. Generates Go code from a TOML configuration file.

cfgx generate [flags]

Flags

FlagShortTypeDefaultDescription
--in-istringconfig.tomlInput TOML file path.
--out-ostring(required)Output Go file path.
--pkg-pstring(auto)Go package name. Inferred from directory if omitted.
--modestringstaticGeneration mode: static or getter.
--no-envboolfalseDisable build-time env var overrides (static mode only).
--max-file-sizestring1MBMax size for file: references.

watch

Watches the input file for changes and re-runs generate automatically.

cfgx watch [flags]

Accepts all flags supported by generate, plus:

FlagTypeDefaultDescription
--debounceint100Debounce delay in milliseconds.

diff

Compares two TOML files. Useful for verifying differences between environment configurations (e.g., dev vs prod).

cfgx diff <file1> <file2> [flags]

Flags

FlagTypeDefaultDescription
--keys-onlyboolfalseShow only keys that differ, ignoring values.
--formatstringtextOutput format: text or json.

Example Output

Differences between config.dev.toml and config.prod.toml:

  server.addr
    - ":8080"     (config.dev.toml)
    + ":443"      (config.prod.toml)

  + server.tls_enabled = true     (only in config.prod.toml)