Skip to main content

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

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