Skip to main content

acp_cli/cli/
mod.rs

1pub mod init;
2pub mod prompt;
3pub mod prompt_source;
4pub mod session;
5
6use clap::{Parser, Subcommand};
7
8#[derive(Parser)]
9#[command(
10    name = "acp-cli",
11    version,
12    about = "Headless CLI client for the Agent Client Protocol"
13)]
14pub struct Cli {
15    /// Agent name (e.g. "claude", "codex") or raw command
16    pub agent: Option<String>,
17
18    /// Prompt text (implicit prompt mode)
19    pub prompt: Vec<String>,
20
21    #[command(subcommand)]
22    pub command: Option<Commands>,
23
24    /// Session name or ID to resume
25    #[arg(short = 's', long)]
26    pub session: Option<String>,
27
28    /// Automatically approve all tool calls
29    #[arg(long)]
30    pub approve_all: bool,
31
32    /// Automatically approve read-only tool calls
33    #[arg(long)]
34    pub approve_reads: bool,
35
36    /// Deny all tool calls
37    #[arg(long)]
38    pub deny_all: bool,
39
40    /// Working directory for the agent
41    #[arg(long)]
42    pub cwd: Option<String>,
43
44    /// Output format (text, json, quiet)
45    #[arg(long, default_value = "text")]
46    pub format: String,
47
48    /// Timeout in seconds
49    #[arg(long)]
50    pub timeout: Option<u64>,
51
52    /// Override the agent command
53    #[arg(long = "agent-override")]
54    pub agent_override: Option<String>,
55
56    /// Read prompt from a file (use "-" for stdin)
57    #[arg(short = 'f', long = "file")]
58    pub file: Option<String>,
59
60    /// Enable verbose output
61    #[arg(long)]
62    pub verbose: bool,
63
64    /// Fire-and-forget: queue the prompt and return immediately without waiting
65    /// for the result. Requires an active session (queue owner) to be running.
66    #[arg(long)]
67    pub no_wait: bool,
68}
69
70#[derive(Subcommand)]
71pub enum Commands {
72    /// Execute a prompt non-interactively
73    Exec {
74        /// Prompt text
75        prompt: Vec<String>,
76    },
77    /// Manage sessions
78    Sessions {
79        #[command(subcommand)]
80        action: SessionAction,
81    },
82    /// Interactive setup — detect auth token, write config
83    Init,
84    /// Manage configuration
85    Config {
86        #[command(subcommand)]
87        action: ConfigAction,
88    },
89    /// Cancel a running prompt by sending SIGTERM
90    Cancel,
91    /// Show status of the current session (running/idle/closed)
92    Status,
93    /// Set the session mode (e.g. "code", "plan", "chat")
94    SetMode {
95        /// Mode identifier to set
96        mode: String,
97    },
98    /// Set a session configuration option
99    Set {
100        /// Configuration key
101        key: String,
102        /// Configuration value
103        value: String,
104    },
105}
106
107#[derive(Subcommand)]
108pub enum SessionAction {
109    /// Create a new session
110    New {
111        /// Optional session name
112        #[arg(long)]
113        name: Option<String>,
114    },
115    /// List existing sessions
116    List,
117    /// Close a session
118    Close {
119        /// Session name
120        #[arg(short = 's', long)]
121        name: Option<String>,
122    },
123    /// Show session details
124    Show {
125        /// Session name
126        #[arg(short = 's', long)]
127        name: Option<String>,
128    },
129    /// Show conversation history
130    History {
131        /// Session name
132        #[arg(short = 's', long)]
133        name: Option<String>,
134    },
135}
136
137#[derive(Subcommand)]
138pub enum ConfigAction {
139    /// Show current configuration
140    Show,
141}