Skip to main content

objectiveai_sdk/cli/command/config/swarms/get/
mod.rs

1//! `config swarms get` — async handler stub.
2
3use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.config.swarms.get.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub filter: Option<String>,
10    pub jq: Option<String>,
11}
12
13#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
14#[schemars(rename = "cli.command.config.swarms.get.Path")]
15pub enum Path {
16    #[serde(rename = "config/swarms/get")]
17    ConfigSwarmsGet,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec!["config".to_string(), "swarms".to_string(), "get".to_string()];
23        if let Some(filter) = &self.filter {
24            argv.push(filter.clone());
25        }
26        if let Some(jq) = &self.jq {
27            argv.push("--jq".to_string());
28            argv.push(jq.clone());
29        }
30        argv
31    }
32}
33
34#[derive(PartialEq, Debug, Clone, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
35#[schemars(rename = "cli.command.config.swarms.get.Response")]
36pub struct Response {
37    #[serde(skip_serializing_if = "Option::is_none")]
38    #[schemars(extend("omitempty" = true))]
39    pub favorites: Option<Vec<super::favorites::get::ResponseItem>>,
40}
41
42#[derive(clap::Args)]
43pub struct Args {
44    /// Optional path filter into the config tree.
45    pub filter: Option<String>,
46    /// jq filter applied to the JSON output.
47    #[arg(long)]
48    pub jq: Option<String>,
49}
50
51#[derive(clap::Args)]
52#[command(args_conflicts_with_subcommands = true)]
53pub struct Command {
54    #[command(flatten)]
55    pub args: Args,
56    #[command(subcommand)]
57    pub schema: Option<Schema>,
58}
59
60#[derive(clap::Subcommand)]
61pub enum Schema {
62    /// Emit the JSON Schema for this leaf's `Request` type and exit.
63    RequestSchema(request_schema::Args),
64    /// Emit the JSON Schema for this leaf's `Response` type and exit.
65    ResponseSchema(response_schema::Args),
66}
67
68impl TryFrom<Args> for Request {
69    type Error = crate::cli::command::FromArgsError;
70    fn try_from(args: Args) -> Result<Self, Self::Error> {
71        Ok(Self { path_type: Path::ConfigSwarmsGet,
72            filter: args.filter,
73            jq: args.jq,
74        })
75    }
76}
77
78#[cfg(feature = "cli-executor")]
79pub async fn execute<E: crate::cli::command::CommandExecutor>(
80    executor: &E,
81    mut request: Request,
82
83        agent_arguments: Option<&crate::cli::command::AgentArguments>,
84    ) -> Result<Response, E::Error> {
85    request.jq = None;
86    executor.execute_one(request, agent_arguments).await
87}
88
89#[cfg(feature = "cli-executor")]
90pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
91    executor: &E,
92    mut request: Request,
93    jq: String,
94
95        agent_arguments: Option<&crate::cli::command::AgentArguments>,
96    ) -> Result<serde_json::Value, E::Error> {
97    request.jq = Some(jq);
98    executor.execute_one(request, agent_arguments).await
99}
100
101#[cfg(feature = "mcp")]
102impl crate::cli::command::CommandResponse for Response {
103    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
104        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
105    }
106}
107
108pub mod request_schema;
109
110
111pub mod response_schema;