Skip to main content

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 doctor;
10pub mod exec;
11pub mod features;
12pub mod fork;
13pub mod login;
14pub mod mcp;
15pub mod mcp_server;
16pub mod plugin;
17pub mod raw;
18pub mod resume;
19pub mod review;
20pub mod sandbox;
21pub mod session_mgmt;
22pub mod update;
23pub mod version;
24
25use std::future::Future;
26
27use crate::Codex;
28use crate::error::Result;
29
30/// Trait implemented by all Codex CLI command builders.
31///
32/// [`args`](CodexCommand::args) returns the CLI arguments the builder would
33/// pass to the `codex` binary. [`execute`](CodexCommand::execute) spawns the
34/// process and returns typed output.
35pub trait CodexCommand: Send + Sync {
36    /// The type returned on success.
37    type Output: Send;
38
39    /// Build the argument list for this command.
40    fn args(&self) -> Vec<String>;
41
42    /// Execute the command against the given [`Codex`] client.
43    fn execute(&self, codex: &Codex) -> impl Future<Output = Result<Self::Output>> + Send;
44}