Files
codex/codex-rs/tui/src/main.rs
T
Benjamin Carlsson 7aa5d4ea3a Deprecate --config and limit it to legacy keys (#65357)
## What changed

Mark `-c` and `--config` as deprecated in CLI help and direct users to
dedicated flags or `config.toml`. Check explicit overrides against a fixed
list of legacy keys before expanding dedicated flags. Reject unknown keys
even without `--strict-config`, including keys inside inline tables and
arrays of tables. The `app-server` subcommand skips the legacy-key check.

Preserve the meaning of positional `features.guardianv3.housekeeper`
overrides by mapping the legacy positions to named fields.

## Testing

Cover unknown nested keys and verify that `codex-exec resume` checks
overrides on both sides of the subcommand while preserving their order.
Test that a legacy positional housekeeper override still sets
`batch_timeout_ms`.

GitOrigin-RevId: ae13d976ad5e13068096c0f2548fdf0ab35535f3
2026-12-02 23:38:59 +00:00

60 lines
1.6 KiB
Rust

// Release builds exceed rustc's default query depth when laying out the async
// MessageProcessor::handle_initialized_client_request future.
#![recursion_limit = "256"]
use clap::Parser;
use codex_arg0::Arg0DispatchPaths;
use codex_arg0::arg0_dispatch_or_else;
use codex_config::LoaderOverrides;
use codex_tui::Cli;
use codex_tui::ExitReason;
use codex_tui::run_main;
use codex_utils_cli::CliConfigOverrides;
use std::io::Write;
#[derive(Parser, Debug)]
struct TopCli {
#[clap(flatten)]
config_overrides: CliConfigOverrides,
#[clap(flatten)]
inner: Cli,
}
fn main() -> anyhow::Result<()> {
codex_build_info::initialize!();
arg0_dispatch_or_else(|arg0_paths: Arg0DispatchPaths| async move {
let top_cli = TopCli::parse();
top_cli
.config_overrides
.legacy_keys()
.map_err(anyhow::Error::msg)?;
let mut inner = top_cli.inner;
inner
.config_overrides
.raw_overrides
.splice(0..0, top_cli.config_overrides.raw_overrides);
let exit_info = run_main(
inner,
arg0_paths,
LoaderOverrides::default(),
/*explicit_remote_endpoint*/ None,
)
.await?;
let is_fatal = match &exit_info.exit_reason {
ExitReason::Fatal(message) => {
eprintln!("ERROR: {message}");
true
}
ExitReason::UserRequested | ExitReason::TurnInterrupted => false,
};
exit_info.print_exit_messages();
if is_fatal {
std::io::stdout().flush()?;
std::process::exit(1);
}
Ok(())
})
}