codex_wrapper/command/mod.rs
1//! Command builders for every Codex CLI subcommand.
2//!
3//! Each subcommand is a builder struct that implements [`CodexCommand`].
4//! Builders accumulate flags via method chaining, then call
5//! [`CodexCommand::execute`] with a [`Codex`] client to run.
6
7pub mod apply;
8pub mod completion;
9pub mod exec;
10pub mod features;
11pub mod fork;
12pub mod login;
13pub mod mcp;
14pub mod mcp_server;
15pub mod raw;
16pub mod resume;
17pub mod review;
18pub mod sandbox;
19pub mod version;
20
21use std::future::Future;
22
23use crate::Codex;
24use crate::error::Result;
25
26/// Trait implemented by all Codex CLI command builders.
27///
28/// [`args`](CodexCommand::args) returns the CLI arguments the builder would
29/// pass to the `codex` binary. [`execute`](CodexCommand::execute) spawns the
30/// process and returns typed output.
31pub trait CodexCommand: Send + Sync {
32 /// The type returned on success.
33 type Output: Send;
34
35 /// Build the argument list for this command.
36 fn args(&self) -> Vec<String>;
37
38 /// Execute the command against the given [`Codex`] client.
39 fn execute(&self, codex: &Codex) -> impl Future<Output = Result<Self::Output>> + Send;
40}