Skip to main content

objectiveai_sdk/cli/command/config/functions/profiles/favorites/get/
mod.rs

1//! `config functions profiles 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.functions.profiles.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.functions.profiles.favorites.get.Path")]
14pub enum Path {
15    #[serde(rename = "config/functions/profiles/favorites/get")]
16    ConfigFunctionsProfilesFavoritesGet,
17}
18impl CommandRequest for Request {
19    fn into_command(&self) -> Vec<String> {
20        let mut argv = vec!["config".to_string(), "functions".to_string(), "profiles".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.functions.profiles.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::ConfigFunctionsProfilesFavoritesGet, jq: args.jq })
66    }
67}
68
69#[cfg(feature = "cli-executor")]
70pub async fn execute<E: crate::cli::command::CommandExecutor>(
71    executor: &E,
72    mut request: Request,
73
74        agent_arguments: Option<&crate::cli::command::AgentArguments>,
75    ) -> Result<E::Stream<ResponseItem>, E::Error> {
76    request.jq = None;
77    executor.execute(request, agent_arguments).await
78}
79
80#[cfg(feature = "cli-executor")]
81pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
82    executor: &E,
83    mut request: Request,
84    jq: String,
85
86        agent_arguments: Option<&crate::cli::command::AgentArguments>,
87    ) -> Result<E::Stream<serde_json::Value>, E::Error> {
88    request.jq = Some(jq);
89    executor.execute(request, agent_arguments).await
90}
91
92#[cfg(feature = "mcp")]
93impl crate::cli::command::CommandResponse for ResponseItem {
94    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
95        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
96    }
97}
98
99pub mod request_schema;
100
101pub mod response_schema;