Skip to main content

acp_cli/cli/
mod.rs

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