use clap::{Parser, Subcommand};
#[derive(Debug, Subcommand, Clone)]
pub enum A2aCommands {
Serve {
#[arg(long, default_value = "127.0.0.1")]
host: String,
#[arg(short, long, default_value_t = 8080)]
port: u16,
#[arg(long)]
base_url: Option<String>,
#[arg(long)]
enable_push: bool,
},
Discover {
agent_url: String,
},
SendTask {
agent_url: String,
message: String,
#[arg(long)]
stream: bool,
#[arg(long)]
context_id: Option<String>,
},
ListTasks {
agent_url: String,
#[arg(long)]
context_id: Option<String>,
#[arg(long, default_value_t = 50)]
limit: u32,
},
GetTask {
agent_url: String,
task_id: String,
},
CancelTask {
agent_url: String,
task_id: String,
},
}
#[derive(Debug, Parser)]
pub struct A2aServeConfig {
#[arg(long, default_value = "127.0.0.1")]
pub host: String,
#[arg(short, long, default_value_t = 8080)]
pub port: u16,
#[arg(long)]
pub base_url: Option<String>,
#[arg(long)]
pub enable_push: bool,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_cli_serve_command() {
let cmd = A2aCommands::Serve {
host: "127.0.0.1".to_string(),
port: 8080,
base_url: Some("http://localhost:8080".to_string()),
enable_push: false,
};
match cmd {
A2aCommands::Serve { port, .. } => assert_eq!(port, 8080),
_ => panic!("Wrong command type"),
}
}
#[test]
fn test_cli_discover_command() {
let cmd = A2aCommands::Discover {
agent_url: "https://example.com".to_string(),
};
match cmd {
A2aCommands::Discover { agent_url } => {
assert_eq!(agent_url, "https://example.com")
}
_ => panic!("Wrong command type"),
}
}
}