objectiveai_sdk/cli/command/swarms/get/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.swarms.get.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub path: crate::RemotePathCommitOptional,
10 #[serde(flatten)]
11 pub base: crate::cli::command::RequestBase,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.swarms.get.Path")]
16pub enum Path {
17 #[serde(rename = "swarms/get")]
18 SwarmsGet,
19}
20
21impl CommandRequest for Request {
22 fn request_base(&self) -> &crate::cli::command::RequestBase {
23 &self.base
24 }
25
26 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
27 Some(&mut self.base)
28 }
29}
30
31#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
33#[schemars(rename = "cli.command.swarms.get.Response")]
34pub struct Response {
35 #[serde(flatten)]
36 #[schemars(schema_with = "crate::flatten_schema::<crate::RemotePath>")]
37 pub path: crate::RemotePath,
38 #[serde(flatten)]
40 #[schemars(schema_with = "crate::flatten_schema::<crate::swarm::RemoteSwarmBase>")]
41 pub inner: crate::swarm::RemoteSwarmBase,
42}
43
44#[cfg(feature = "mcp")]
45impl crate::cli::command::CommandResponse for Response {
46 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
47 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
48 }
49}
50
51#[derive(clap::Args)]
52#[command(group(clap::ArgGroup::new("path_required").required(true).args(["path"])))]
53pub struct Args {
54 #[arg(long)]
56 pub path: Option<String>,
57 #[command(flatten)]
58 pub base: crate::cli::command::RequestBaseArgs,
59}
60
61#[derive(clap::Args)]
62#[command(args_conflicts_with_subcommands = true)]
63pub struct Command {
64 #[command(flatten)]
65 pub args: Args,
66 #[command(subcommand)]
67 pub schema: Option<Schema>,
68}
69
70#[derive(clap::Subcommand)]
71pub enum Schema {
72 RequestSchema(request_schema::Args),
74 ResponseSchema(response_schema::Args),
76}
77
78impl TryFrom<Args> for Request {
79 type Error = crate::cli::command::FromArgsError;
80 fn try_from(args: Args) -> Result<Self, Self::Error> {
81 let path = args
82 .path
83 .ok_or_else(|| {
84 crate::cli::command::FromArgsError::path_parse(
85 "path",
86 "--path is required".to_string(),
87 )
88 })?
89 .parse::<crate::RemotePathCommitOptional>()
90 .map_err(|msg| crate::cli::command::FromArgsError::path_parse("path", msg))?;
91 Ok(Self { path_type: Path::SwarmsGet, path, base: args.base.into() })
92 }
93}
94
95#[cfg(feature = "cli-executor")]
96pub async fn execute<E: crate::cli::command::CommandExecutor>(
97 executor: &E,
98 mut request: Request,
99
100 agent_arguments: Option<&crate::cli::command::AgentArguments>,
101 ) -> Result<Response, E::Error> {
102 request.base.clear_transform();
103 executor.execute_one(request, agent_arguments).await
104}
105
106#[cfg(feature = "cli-executor")]
107pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
108 executor: &E,
109 mut request: Request,
110 transform: crate::cli::command::Transform,
111
112 agent_arguments: Option<&crate::cli::command::AgentArguments>,
113 ) -> Result<serde_json::Value, E::Error> {
114 request.base.set_transform(transform);
115 executor.execute_one(request, agent_arguments).await
116}
117
118pub mod request_schema;
119
120
121pub mod response_schema;