Skip to content

feat(cli): override config with repeatable -c key=value flags - #431

Merged
fcoury merged 1 commit into
mainfrom
explore/cli-config-overrides
Nov 3, 2026
Merged

fcoury merged 1 commit into
mainfrom
explore/cli-config-overrides

Conversation

@fcoury

@fcoury fcoury commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Red could already merge inline TOML fragments with -c/--config-override, but a one-off launch still could not set a single dotted key the way Codex does. Unquoted values such as theme=onedark.json failed to parse, unknown keys were reported only by override index, and there was no way to print the merged result.

This adds Codex-style repeatable -c/--config key=value overrides. key is a dotted path. value is parsed as TOML, and a value that is not valid TOML is kept as a plain string, so quotes are optional for ordinary text. Arrays and inline tables use normal TOML. Repeated flags apply in order and the last one wins. --config-override remains an alias and still accepts a TOML document.

Precedence, from lowest to highest:

  1. Embedded defaults
  2. config.toml ($XDG_CONFIG_HOME/red/config.toml, otherwise ~/.config/red/config.toml)
  3. -c / --config / --config-override

Red does not load configuration from an environment variable. XDG_CONFIG_HOME only selects the config directory. Invalid overrides fail the process: the message names the flag text, and a close key gets a suggestion. red --print-config prints the merged configuration, and :config-diagnostics lists the startup overrides next to any config problems.

CLI config overrides

Latte theme, syntax colors, and a two-space indent

How to Test

git fetch origin explore/cli-config-overrides && git checkout explore/cli-config-overrides
cargo build

Show the merged configuration. The theme and indent width come from the flags, and a repeated scrolloff keeps the last value:

cargo run -- --print-config \
  -c theme=onedark.json \
  -c languages.rust.indent_width=2 \
  -c scrolloff=8 \
  -c scrolloff=4

An unknown key names the flag and suggests the closest setting:

cargo run -- --print-config -c themee=onedark.json

Launch the editor with a theme and a Rust indent width. The status line shows spaces:2 after adding indentation to the right side:

cargo run -- \
  -c theme=latte.json \
  -c languages.rust.indent_width=2 \
  -c "statusline.right=['indentation','position']" \
  src/main.rs

Automated coverage:

cargo test --lib -- config::config_override::tests cli::tests::config_help_documents_key_value_overrides
cargo test --test cli_config_override
Open in Web Open in Cursor 

Accept dotted -c/--config values on top of defaults and config.toml. Values
parse as TOML and fall back to plain strings, and invalid flags name the
offending override.

Co-authored-by: Felipe Coury <[email protected]>
@fcoury
fcoury marked this pull request as ready for review November 3, 2026 03:34
@fcoury

fcoury commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T03:35:57.517855Z e976a22 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: e976a22aa5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fcoury
fcoury merged commit ba5e331 into main Nov 3, 2026
23 checks passed
@fcoury
fcoury deleted the explore/cli-config-overrides branch November 3, 2026 03:36
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.

1 participant