Skip to main content

objectiveai_sdk/cli/command/config/functions/inventions/remote/get/
mod.rs

1//! `config functions inventions remote 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.inventions.remote.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.functions.inventions.remote.get.Path")]
15pub enum Path {
16    #[serde(rename = "config/functions/inventions/remote/get")]
17    ConfigFunctionsInventionsRemoteGet,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec!["config".to_string(), "functions".to_string(), "inventions".to_string(), "remote".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
34pub type Response = crate::Remote;
35
36#[derive(clap::Args)]
37pub struct Args {
38    /// Optional path filter into the config tree.
39    pub filter: Option<String>,
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::ConfigFunctionsInventionsRemoteGet,
66            filter: args.filter,
67            jq: args.jq,
68        })
69    }
70}
71
72#[cfg(feature = "cli-executor")]
73pub async fn execute<E: crate::cli::command::CommandExecutor>(
74    executor: &E,
75    mut request: Request,
76
77        agent_arguments: Option<&crate::cli::command::AgentArguments>,
78    ) -> Result<Response, E::Error> {
79    request.jq = None;
80    executor.execute_one(request, agent_arguments).await
81}
82
83#[cfg(feature = "cli-executor")]
84pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
85    executor: &E,
86    mut request: Request,
87    jq: String,
88
89        agent_arguments: Option<&crate::cli::command::AgentArguments>,
90    ) -> Result<serde_json::Value, E::Error> {
91    request.jq = Some(jq);
92    executor.execute_one(request, agent_arguments).await
93}
94
95pub mod request_schema;
96
97
98pub mod response_schema;