mirror of
https://github.com/openai/codex.git
synced 2026-05-05 22:01:37 +03:00
## Why `codex-rs/exec/src/lib.rs` already keeps unit tests in a sibling `lib_tests.rs` module so the implementation stays top-heavy and easier to read. This applies that same layout to the rest of `codex-rs/exec/src` so each production file keeps its entry points and helpers ahead of test code. ## What - Move inline unit tests out of `cli.rs`, `main.rs`, `event_processor_with_human_output.rs`, and `event_processor_with_jsonl_output.rs` into sibling `*_tests.rs` files. - Keep test modules wired through `#[cfg(test)]` plus `#[path = "..."] mod tests;`, matching the `lib.rs` pattern. - Preserve the existing test coverage and assertions while making this a source-layout-only refactor. ## Verification - `cargo test -p codex-exec`
46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
//! Entry-point for the `codex-exec` binary.
|
|
//!
|
|
//! When this CLI is invoked normally, it parses the standard `codex-exec` CLI
|
|
//! options and launches the non-interactive Codex agent. However, if it is
|
|
//! invoked with arg0 as `codex-linux-sandbox`, we instead treat the invocation
|
|
//! as a request to run the logic for the standalone `codex-linux-sandbox`
|
|
//! executable (i.e., parse any -s args and then run a *sandboxed* command under
|
|
//! Landlock + seccomp.
|
|
//!
|
|
//! This allows us to ship a completely separate set of functionality as part
|
|
//! of the `codex-exec` binary.
|
|
use clap::Parser;
|
|
use codex_arg0::Arg0DispatchPaths;
|
|
use codex_arg0::arg0_dispatch_or_else;
|
|
use codex_exec::Cli;
|
|
use codex_exec::run_main;
|
|
use codex_utils_cli::CliConfigOverrides;
|
|
|
|
#[derive(Parser, Debug)]
|
|
struct TopCli {
|
|
#[clap(flatten)]
|
|
config_overrides: CliConfigOverrides,
|
|
|
|
#[clap(flatten)]
|
|
inner: Cli,
|
|
}
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
arg0_dispatch_or_else(|arg0_paths: Arg0DispatchPaths| async move {
|
|
let top_cli = TopCli::parse();
|
|
// Merge root-level overrides into inner CLI struct so downstream logic remains unchanged.
|
|
let mut inner = top_cli.inner;
|
|
inner
|
|
.config_overrides
|
|
.raw_overrides
|
|
.splice(0..0, top_cli.config_overrides.raw_overrides);
|
|
|
|
run_main(inner, arg0_paths).await?;
|
|
Ok(())
|
|
})
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "main_tests.rs"]
|
|
mod tests;
|