Skip to main content

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

1//! `config api 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.api.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.api.get.Path")]
15pub enum Path {
16    #[serde(rename = "config/api/get")]
17    ConfigApiGet,
18}
19
20impl CommandRequest for Request {
21    fn into_command(&self) -> Vec<String> {
22        let mut argv = vec!["config".to_string(), "api".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.api.get.Response")]
36pub struct Response {
37    #[serde(skip_serializing_if = "Option::is_none")]
38    #[schemars(extend("omitempty" = true))]
39    pub address: Option<String>,
40    #[serde(skip_serializing_if = "Option::is_none")]
41    #[schemars(extend("omitempty" = true))]
42    pub port: Option<u16>,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[schemars(extend("omitempty" = true))]
45    pub claude_agent_sdk: Option<bool>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    #[schemars(extend("omitempty" = true))]
48    pub codex_sdk: Option<bool>,
49    #[serde(skip_serializing_if = "Option::is_none")]
50    #[schemars(extend("omitempty" = true))]
51    pub objectiveai_authorization: Option<String>,
52    #[serde(skip_serializing_if = "Option::is_none")]
53    #[schemars(extend("omitempty" = true))]
54    pub openrouter_authorization: Option<String>,
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[schemars(extend("omitempty" = true))]
57    pub github_authorization: Option<String>,
58    #[serde(skip_serializing_if = "Option::is_none")]
59    #[schemars(extend("omitempty" = true))]
60    pub mcp_authorization: Option<indexmap::IndexMap<String, String>>,
61    #[serde(skip_serializing_if = "Option::is_none")]
62    #[schemars(extend("omitempty" = true))]
63    pub user_agent: Option<String>,
64    #[serde(skip_serializing_if = "Option::is_none")]
65    #[schemars(extend("omitempty" = true))]
66    pub http_referer: Option<String>,
67    #[serde(skip_serializing_if = "Option::is_none")]
68    #[schemars(extend("omitempty" = true))]
69    pub x_title: Option<String>,
70    #[serde(skip_serializing_if = "Option::is_none")]
71    #[schemars(extend("omitempty" = true))]
72    pub commit_author_name: Option<String>,
73    #[serde(skip_serializing_if = "Option::is_none")]
74    #[schemars(extend("omitempty" = true))]
75    pub commit_author_email: Option<String>,
76}
77
78#[derive(clap::Args)]
79pub struct Args {
80    /// Optional path filter into the config tree.
81    pub filter: Option<String>,
82    /// jq filter applied to the JSON output.
83    #[arg(long)]
84    pub jq: Option<String>,
85}
86
87#[derive(clap::Args)]
88#[command(args_conflicts_with_subcommands = true)]
89pub struct Command {
90    #[command(flatten)]
91    pub args: Args,
92    #[command(subcommand)]
93    pub schema: Option<Schema>,
94}
95
96#[derive(clap::Subcommand)]
97pub enum Schema {
98    /// Emit the JSON Schema for this leaf's `Request` type and exit.
99    RequestSchema(request_schema::Args),
100    /// Emit the JSON Schema for this leaf's `Response` type and exit.
101    ResponseSchema(response_schema::Args),
102}
103
104impl TryFrom<Args> for Request {
105    type Error = crate::cli::command::FromArgsError;
106    fn try_from(args: Args) -> Result<Self, Self::Error> {
107        Ok(Self { path_type: Path::ConfigApiGet,
108            filter: args.filter,
109            jq: args.jq,
110        })
111    }
112}
113
114#[cfg(feature = "cli-executor")]
115pub async fn execute<E: crate::cli::command::CommandExecutor>(
116    executor: &E,
117    mut request: Request,
118
119        agent_arguments: Option<&crate::cli::command::AgentArguments>,
120    ) -> Result<Response, E::Error> {
121    request.jq = None;
122    executor.execute_one(request, agent_arguments).await
123}
124
125#[cfg(feature = "cli-executor")]
126pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
127    executor: &E,
128    mut request: Request,
129    jq: String,
130
131        agent_arguments: Option<&crate::cli::command::AgentArguments>,
132    ) -> Result<serde_json::Value, E::Error> {
133    request.jq = Some(jq);
134    executor.execute_one(request, agent_arguments).await
135}
136
137#[cfg(feature = "mcp")]
138impl crate::cli::command::CommandResponse for Response {
139    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
140        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
141    }
142}
143
144pub mod request_schema;
145
146
147pub mod response_schema;