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    /// Manage saved workspace manifests.
20    Workspace(WorkspaceArgs),
21}
22
23/// Arguments used to launch a workspace sandbox.
24#[derive(Debug, Parser)]
25pub struct RunArgs {
26    /// Provider configuration name to load from the local configuration database.
27    #[arg(short, long)]
28    pub provider: String,
29
30    /// Workspace name or path to a workspace manifest YAML file.
31    #[arg(short, long, value_name = "WORKSPACE")]
32    pub workspace: PathBuf,
33
34    /// Path to the local provider configuration database.
35    #[arg(long, value_name = "PATH", default_value = "~/.cc-switch/cc-switch.db")]
36    pub config_db: PathBuf,
37
38    /// Host directory used to store per-workspace Codex sessions.
39    #[arg(long, value_name = "PATH", default_value = "~/.codex-ws")]
40    pub sessions_root: PathBuf,
41
42    /// Docker image containing the Codex CLI.
43    #[arg(long, value_name = "IMAGE")]
44    pub image: Option<String>,
45}
46
47/// Arguments used to manage saved workspace manifests.
48#[derive(Debug, Parser)]
49pub struct WorkspaceArgs {
50    #[command(subcommand)]
51    pub command: WorkspaceCommand,
52}
53
54/// Workspace manifest management commands.
55#[derive(Debug, Subcommand)]
56pub enum WorkspaceCommand {
57    /// List saved workspace manifests.
58    Ls(WorkspaceLsArgs),
59
60    /// Create or edit a saved workspace manifest.
61    Add(WorkspaceAddArgs),
62}
63
64/// Arguments used to list saved workspace manifests.
65#[derive(Debug, Parser)]
66pub struct WorkspaceLsArgs {
67    /// Host directory used to store codex-ws state and saved workspace manifests.
68    #[arg(long, value_name = "PATH", default_value = "~/.codex-ws")]
69    pub sessions_root: PathBuf,
70}
71
72/// Arguments used to add a saved workspace manifest.
73#[derive(Debug, Parser)]
74pub struct WorkspaceAddArgs {
75    /// Workspace name used for the saved manifest file.
76    pub workspace_name: String,
77
78    /// Host directory used to store codex-ws state and saved workspace manifests.
79    #[arg(long, value_name = "PATH", default_value = "~/.codex-ws")]
80    pub sessions_root: PathBuf,
81}