objectiveai_sdk/cli/command/config/viewer/port/get/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.config.viewer.port.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.viewer.port.get.Path")]
15pub enum Path {
16 #[serde(rename = "config/viewer/port/get")]
17 ConfigViewerPortGet,
18}
19
20impl CommandRequest for Request {
21 fn into_command(&self) -> Vec<String> {
22 let mut argv = vec!["config".to_string(), "viewer".to_string(), "port".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(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
35#[schemars(rename = "cli.command.config.viewer.port.get.Response")]
36pub struct Response {
37 pub port: u16,
38}
39
40#[derive(clap::Args)]
41pub struct Args {
42 pub filter: Option<String>,
44 #[arg(long)]
46 pub jq: Option<String>,
47}
48
49#[derive(clap::Args)]
50#[command(args_conflicts_with_subcommands = true)]
51pub struct Command {
52 #[command(flatten)]
53 pub args: Args,
54 #[command(subcommand)]
55 pub schema: Option<Schema>,
56}
57
58#[derive(clap::Subcommand)]
59pub enum Schema {
60 RequestSchema(request_schema::Args),
62 ResponseSchema(response_schema::Args),
64}
65
66impl TryFrom<Args> for Request {
67 type Error = crate::cli::command::FromArgsError;
68 fn try_from(args: Args) -> Result<Self, Self::Error> {
69 Ok(Self { path_type: Path::ConfigViewerPortGet,
70 filter: args.filter,
71 jq: args.jq,
72 })
73 }
74}
75
76#[cfg(feature = "cli-executor")]
77pub async fn execute<E: crate::cli::command::CommandExecutor>(
78 executor: &E,
79 mut request: Request,
80
81 agent_arguments: Option<&crate::cli::command::AgentArguments>,
82 ) -> Result<Response, E::Error> {
83 request.jq = None;
84 executor.execute_one(request, agent_arguments).await
85}
86
87#[cfg(feature = "cli-executor")]
88pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
89 executor: &E,
90 mut request: Request,
91 jq: String,
92
93 agent_arguments: Option<&crate::cli::command::AgentArguments>,
94 ) -> Result<serde_json::Value, E::Error> {
95 request.jq = Some(jq);
96 executor.execute_one(request, agent_arguments).await
97}
98
99#[cfg(feature = "mcp")]
100impl crate::cli::command::CommandResponse for Response {
101 fn into_mcp(self) -> crate::cli::command::McpResponseItem {
102 crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
103 }
104}
105
106pub mod request_schema;
107
108
109pub mod response_schema;