Skip to main content

codex_ws/
cli.rs

1use std::path::PathBuf;
2
3use clap::{Parser, Subcommand};
4
5/// Launch and manage Codex CLI workspaces.
6#[derive(Debug, Parser)]
7#[command(name = "codex-ws", version, about)]
8pub struct Cli {
9    #[command(subcommand)]
10    pub command: Command,
11}
12
13/// Commands supported by the `codex-ws` CLI.
14#[derive(Debug, Subcommand)]
15pub enum Command {
16    /// Launch a Codex sandbox for a workspace manifest.
17    Run(RunArgs),
18
19    /// Read or update codex-ws user configuration.
20    Config(ConfigArgs),
21
22    /// Manage saved workspace manifests.
23    Workspace(WorkspaceArgs),
24}
25
26/// Arguments used to launch a workspace sandbox.
27#[derive(Debug, Parser)]
28pub struct RunArgs {
29    /// Provider configuration name to load from the local configuration database.
30    #[arg(short, long)]
31    pub provider: String,
32
33    /// Workspace name or path to a workspace manifest YAML file.
34    #[arg(short, long, value_name = "WORKSPACE")]
35    pub workspace: PathBuf,
36
37    /// Path to the local provider configuration database.
38    #[arg(long, value_name = "PATH")]
39    pub config_db: Option<PathBuf>,
40
41    /// Host directory used to store per-workspace Codex sessions.
42    #[arg(long, value_name = "PATH")]
43    pub sessions_root: Option<PathBuf>,
44
45    /// Docker image containing the Codex CLI.
46    #[arg(long, value_name = "IMAGE")]
47    pub image: Option<String>,
48}
49
50/// Arguments used to read or update user configuration.
51#[derive(Debug, Parser)]
52pub struct ConfigArgs {
53    #[command(subcommand)]
54    pub command: ConfigCommand,
55}
56
57/// User configuration commands.
58#[derive(Debug, Subcommand)]
59pub enum ConfigCommand {
60    /// Read one config value, or all configured values when no name is provided.
61    Get(ConfigGetArgs),
62
63    /// Set a supported config value.
64    Set(ConfigSetArgs),
65}
66
67/// Arguments used to read user configuration.
68#[derive(Debug, Parser)]
69pub struct ConfigGetArgs {
70    /// Optional config name to read.
71    pub config_name: Option<String>,
72}
73
74/// Arguments used to update user configuration.
75#[derive(Debug, Parser)]
76pub struct ConfigSetArgs {
77    /// Supported config name.
78    pub config_name: String,
79
80    /// Config value to persist.
81    pub config_value: PathBuf,
82}
83
84/// Arguments used to manage saved workspace manifests.
85#[derive(Debug, Parser)]
86pub struct WorkspaceArgs {
87    #[command(subcommand)]
88    pub command: WorkspaceCommand,
89}
90
91/// Workspace manifest management commands.
92#[derive(Debug, Subcommand)]
93pub enum WorkspaceCommand {
94    /// List saved workspace manifests.
95    Ls(WorkspaceLsArgs),
96
97    /// Create or edit a saved workspace manifest.
98    Add(WorkspaceAddArgs),
99}
100
101/// Arguments used to list saved workspace manifests.
102#[derive(Debug, Parser)]
103pub struct WorkspaceLsArgs {
104    /// Host directory used to store codex-ws state and saved workspace manifests.
105    #[arg(long, value_name = "PATH")]
106    pub sessions_root: Option<PathBuf>,
107}
108
109/// Arguments used to add a saved workspace manifest.
110#[derive(Debug, Parser)]
111pub struct WorkspaceAddArgs {
112    /// Workspace name used for the saved manifest file.
113    pub workspace_name: String,
114
115    /// Host directory used to store codex-ws state and saved workspace manifests.
116    #[arg(long, value_name = "PATH")]
117    pub sessions_root: Option<PathBuf>,
118}