Skip to main content

objectiveai_cli/command/api/config/
get.rs

1//! `config api get` — read the api section of on-disk config (every
2//! `ApiConfig` field). Missing fields stay `None`.
3
4use objectiveai_sdk::cli::command::api::config::get::{Request, Response};
5
6use crate::context::Context;
7use crate::error::Error;
8
9pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
10    let mut config = ctx.filesystem.read_config_view(request.scope).await?;
11    let api = config.api();
12    Ok(Response {
13        address: api.get_address().map(String::from),
14        objectiveai_authorization: api.get_objectiveai_authorization().map(String::from),
15        openrouter_authorization: api.get_openrouter_authorization().map(String::from),
16        github_authorization: api.get_github_authorization().map(String::from),
17        mcp_authorization: api.get_mcp_authorization().cloned(),
18        user_agent: api.get_user_agent().map(String::from),
19        http_referer: api.get_http_referer().map(String::from),
20        x_title: api.get_x_title().map(String::from),
21        commit_author_name: api.get_commit_author_name().map(String::from),
22        commit_author_email: api.get_commit_author_email().map(String::from),
23    })
24}
25
26pub mod request_schema {
27    use objectiveai_sdk::cli::command::api::config::get as sdk;
28    use objectiveai_sdk::cli::command::api::config::get::request_schema::{Request, Response};
29
30    use crate::context::Context;
31    use crate::error::Error;
32
33    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
34        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Request)))
35    }
36}
37
38pub mod response_schema {
39    use objectiveai_sdk::cli::command::api::config::get as sdk;
40    use objectiveai_sdk::cli::command::api::config::get::response_schema::{Request, Response};
41
42    use crate::context::Context;
43    use crate::error::Error;
44
45    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
46        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Response)))
47    }
48}