objectiveai_sdk/cli/command/config/agents/favorites/get/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.config.agents.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.agents.favorites.get.Path")]
14pub enum Path {
15 #[serde(rename = "config/agents/favorites/get")]
16 ConfigAgentsFavoritesGet,
17}
18impl CommandRequest for Request {
19 fn into_command(&self) -> Vec<String> {
20 let mut argv = vec![
21 "config".to_string(),
22 "agents".to_string(),
23 "favorites".to_string(),
24 "get".to_string(),
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(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
35#[schemars(rename = "cli.command.config.agents.favorites.get.ResponseItem")]
36pub struct ResponseItem {
37 pub name: String,
38 #[serde(flatten)]
39 pub path: crate::RemotePathCommitOptional,
40 pub note: String,
41}
42
43#[derive(clap::Args)]
44pub struct Args {
45 #[arg(long)]
47 pub jq: Option<String>,
48}
49
50#[derive(clap::Args)]
51#[command(args_conflicts_with_subcommands = true)]
52pub struct Command {
53 #[command(flatten)]
54 pub args: Args,
55 #[command(subcommand)]
56 pub schema: Option<Schema>,
57}
58
59#[derive(clap::Subcommand)]
60pub enum Schema {
61 RequestSchema(request_schema::Args),
63 ResponseSchema(response_schema::Args),
65}
66
67impl TryFrom<Args> for Request {
68 type Error = crate::cli::command::FromArgsError;
69 fn try_from(args: Args) -> Result<Self, Self::Error> {
70 Ok(Self { path_type: Path::ConfigAgentsFavoritesGet, jq: args.jq })
71 }
72}
73
74#[cfg(feature = "cli-executor")]
75pub async fn execute<E: crate::cli::command::CommandExecutor>(
76 executor: &E,
77 mut request: Request,
78
79 agent_arguments: Option<&crate::cli::command::AgentArguments>,
80 ) -> Result<E::Stream<ResponseItem>, E::Error> {
81 request.jq = None;
82 executor.execute(request, agent_arguments).await
83}
84
85#[cfg(feature = "cli-executor")]
86pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
87 executor: &E,
88 mut request: Request,
89 jq: String,
90
91 agent_arguments: Option<&crate::cli::command::AgentArguments>,
92 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
93 request.jq = Some(jq);
94 executor.execute(request, agent_arguments).await
95}
96
97#[cfg(feature = "mcp")]
98impl crate::cli::command::CommandResponse for ResponseItem {
99 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
100 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
101 }
102}
103
104pub mod request_schema;
105
106pub mod response_schema;