I started this PR because I wanted to share the `format_duration()`
utility function in `codex-rs/exec/src/event_processor.rs` with the TUI.
The question was: where to put it?
`core` should have as few dependencies as possible, so moving it there
would introduce a dependency on `chrono`, which seemed undesirable.
`core` already had this `cli` feature to deal with a similar situation
around sharing common utility functions, so I decided to:
* make `core` feature-free
* introduce `common`
* `common` can have as many "special interest" features as it needs,
each of which can declare their own deps
* the first two features of common are `cli` and `elapsed`
In practice, this meant updating a number of `Cargo.toml` files,
replacing this line:
```toml
codex-core = { path = "../core", features = ["cli"] }
```
with these:
```toml
codex-core = { path = "../core" }
codex-common = { path = "../common", features = ["cli"] }
```
Moving `format_duration()` into its own file gave it some "breathing
room" to add a unit test, so I had Codex generate some tests and new
support for durations over 1 minute.
42 lines
1.5 KiB
Rust
42 lines
1.5 KiB
Rust
use clap::Parser;
|
||
use codex_common::ApprovalModeCliArg;
|
||
use codex_common::SandboxPermissionOption;
|
||
use std::path::PathBuf;
|
||
|
||
#[derive(Parser, Debug)]
|
||
#[command(version)]
|
||
pub struct Cli {
|
||
/// Optional user prompt to start the session.
|
||
pub prompt: Option<String>,
|
||
|
||
/// Optional image(s) to attach to the initial prompt.
|
||
#[arg(long = "image", short = 'i', value_name = "FILE", value_delimiter = ',', num_args = 1..)]
|
||
pub images: Vec<PathBuf>,
|
||
|
||
/// Model the agent should use.
|
||
#[arg(long, short = 'm')]
|
||
pub model: Option<String>,
|
||
|
||
/// Configure when the model requires human approval before executing a command.
|
||
#[arg(long = "ask-for-approval", short = 'a')]
|
||
pub approval_policy: Option<ApprovalModeCliArg>,
|
||
|
||
/// Convenience alias for low-friction sandboxed automatic execution (-a on-failure, network-disabled sandbox that can write to cwd and TMPDIR)
|
||
#[arg(long = "full-auto", default_value_t = false)]
|
||
pub full_auto: bool,
|
||
|
||
#[clap(flatten)]
|
||
pub sandbox: SandboxPermissionOption,
|
||
|
||
/// Tell the agent to use the specified directory as its working root.
|
||
#[clap(long = "cd", short = 'C', value_name = "DIR")]
|
||
pub cwd: Option<PathBuf>,
|
||
|
||
/// Allow running Codex outside a Git repository.
|
||
#[arg(long = "skip-git-repo-check", default_value_t = false)]
|
||
pub skip_git_repo_check: bool,
|
||
|
||
/// Disable server‑side response storage (sends the full conversation context with every request)
|
||
#[arg(long = "disable-response-storage", default_value_t = false)]
|
||
pub disable_response_storage: bool,
|
||
}
|