agcodex_exec/
cli.rs

1use agcodex_common::CliConfigOverrides;
2use clap::Parser;
3use clap::ValueEnum;
4use std::path::PathBuf;
5
6#[derive(Parser, Debug)]
7#[command(version)]
8pub struct Cli {
9    /// Optional image(s) to attach to the initial prompt.
10    #[arg(long = "image", short = 'i', value_name = "FILE", value_delimiter = ',', num_args = 1..)]
11    pub images: Vec<PathBuf>,
12
13    /// Model the agent should use.
14    #[arg(long, short = 'm')]
15    pub model: Option<String>,
16
17    #[arg(long = "oss", default_value_t = false)]
18    pub oss: bool,
19
20    /// Select the sandbox policy to use when executing model-generated shell
21    /// commands.
22    #[arg(long = "sandbox", short = 's', value_enum)]
23    pub sandbox_mode: Option<agcodex_common::SandboxModeCliArg>,
24
25    /// Configuration profile from config.toml to specify default options.
26    #[arg(long = "profile", short = 'p')]
27    pub config_profile: Option<String>,
28
29    /// Convenience alias for low-friction sandboxed automatic execution (-a on-failure, --sandbox workspace-write).
30    #[arg(long = "full-auto", default_value_t = false)]
31    pub full_auto: bool,
32
33    /// Skip all confirmation prompts and execute commands without sandboxing.
34    /// EXTREMELY DANGEROUS. Intended solely for running in environments that are externally sandboxed.
35    #[arg(
36        long = "dangerously-bypass-approvals-and-sandbox",
37        alias = "yolo",
38        default_value_t = false,
39        conflicts_with = "full_auto"
40    )]
41    pub dangerously_bypass_approvals_and_sandbox: bool,
42
43    /// Tell the agent to use the specified directory as its working root.
44    #[clap(long = "cd", short = 'C', value_name = "DIR")]
45    pub cwd: Option<PathBuf>,
46
47    /// Allow running Codex outside a Git repository.
48    #[arg(long = "skip-git-repo-check", default_value_t = false)]
49    pub skip_git_repo_check: bool,
50
51    #[clap(skip)]
52    pub config_overrides: CliConfigOverrides,
53
54    /// Specifies color settings for use in the output.
55    #[arg(long = "color", value_enum, default_value_t = Color::Auto)]
56    pub color: Color,
57
58    /// Print events to stdout as JSONL.
59    #[arg(long = "json", default_value_t = false)]
60    pub json: bool,
61
62    /// Specifies file where the last message from the agent should be written.
63    #[arg(long = "output-last-message")]
64    pub last_message_file: Option<PathBuf>,
65
66    /// Initial instructions for the agent. If not provided as an argument (or
67    /// if `-` is used), instructions are read from stdin.
68    #[arg(value_name = "PROMPT")]
69    pub prompt: Option<String>,
70}
71
72#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
73#[value(rename_all = "kebab-case")]
74pub enum Color {
75    Always,
76    Never,
77    #[default]
78    Auto,
79}