Skip to main content

objectiveai_cli/command/viewer/config/
get.rs

1//! `config viewer get` — read the viewer section of on-disk config
2//! (address + port + secret + signature). Missing fields stay `None`.
3
4use objectiveai_sdk::cli::command::viewer::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 viewer = config.viewer();
12    Ok(Response {
13        address: viewer.get_address().map(String::from),
14        secret: viewer.get_secret().map(String::from),
15        signature: viewer.get_signature().map(String::from),
16    })
17}
18
19pub mod request_schema {
20    use objectiveai_sdk::cli::command::viewer::config::get as sdk;
21    use objectiveai_sdk::cli::command::viewer::config::get::request_schema::{Request, Response};
22
23    use crate::context::Context;
24    use crate::error::Error;
25
26    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
27        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Request)))
28    }
29}
30
31pub mod response_schema {
32    use objectiveai_sdk::cli::command::viewer::config::get as sdk;
33    use objectiveai_sdk::cli::command::viewer::config::get::response_schema::{Request, Response};
34
35    use crate::context::Context;
36    use crate::error::Error;
37
38    pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
39        Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Response)))
40    }
41}