objectiveai_sdk/cli/command/viewer/config/get/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.viewer.config.get.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub scope: crate::cli::command::GetScope,
10 #[serde(flatten)]
11 pub base: crate::cli::command::RequestBase,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.viewer.config.get.Path")]
16pub enum Path {
17 #[serde(rename = "viewer/config/get")]
18 ViewerConfigGet,
19}
20
21impl CommandRequest for Request {
22 fn request_base(&self) -> &crate::cli::command::RequestBase {
23 &self.base
24 }
25
26 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
27 Some(&mut self.base)
28 }
29}
30
31#[derive(PartialEq, Debug, Clone, Default, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
32#[schemars(rename = "cli.command.viewer.config.get.Response")]
33pub struct Response {
34 #[serde(skip_serializing_if = "Option::is_none")]
35 #[schemars(extend("omitempty" = true))]
36 pub address: Option<String>,
37 #[serde(skip_serializing_if = "Option::is_none")]
38 #[schemars(extend("omitempty" = true))]
39 pub secret: Option<String>,
40 #[serde(skip_serializing_if = "Option::is_none")]
41 #[schemars(extend("omitempty" = true))]
42 pub signature: Option<String>,
43}
44
45#[derive(clap::Args)]
46pub struct Args {
47 #[arg(long)]
49 pub global: bool,
50 #[arg(long)]
52 pub state: bool,
53 #[arg(long)]
55 pub r#final: bool,
56 #[command(flatten)]
57 pub base: crate::cli::command::RequestBaseArgs,
58}
59
60#[derive(clap::Args)]
61#[command(args_conflicts_with_subcommands = true)]
62pub struct Command {
63 #[command(flatten)]
64 pub args: Args,
65 #[command(subcommand)]
66 pub schema: Option<Schema>,
67}
68
69#[derive(clap::Subcommand)]
70pub enum Schema {
71 RequestSchema(request_schema::Args),
73 ResponseSchema(response_schema::Args),
75}
76
77impl TryFrom<Args> for Request {
78 type Error = crate::cli::command::FromArgsError;
79 fn try_from(args: Args) -> Result<Self, Self::Error> {
80 let scope = match (args.global, args.state, args.r#final) {
81 (true, false, false) => crate::cli::command::GetScope::Global,
82 (false, true, false) => crate::cli::command::GetScope::State,
83 (false, false, true) => crate::cli::command::GetScope::Final,
84 _ => {
85 return Err(crate::cli::command::FromArgsError {
86 field: "scope",
87 source: crate::cli::command::FromArgsErrorSource::Plain(
88 "exactly one of --global, --state, --final is required".to_string(),
89 ),
90 });
91 }
92 };
93 Ok(Self { path_type: Path::ViewerConfigGet,
94 scope,
95 base: args.base.into(),
96 })
97 }
98}
99
100#[cfg(feature = "cli-executor")]
101pub async fn execute<E: crate::cli::command::CommandExecutor>(
102 executor: &E,
103 mut request: Request,
104
105 agent_arguments: Option<&crate::cli::command::AgentArguments>,
106 ) -> Result<Response, E::Error> {
107 request.base.clear_transform();
108 executor.execute_one(request, agent_arguments).await
109}
110
111#[cfg(feature = "cli-executor")]
112pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
113 executor: &E,
114 mut request: Request,
115 transform: crate::cli::command::Transform,
116
117 agent_arguments: Option<&crate::cli::command::AgentArguments>,
118 ) -> Result<serde_json::Value, E::Error> {
119 request.base.set_transform(transform);
120 executor.execute_one(request, agent_arguments).await
121}
122
123#[cfg(feature = "mcp")]
124impl crate::cli::command::CommandResponse for Response {
125 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
126 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
127 }
128}
129
130pub mod request_schema;
131
132
133pub mod response_schema;