Skip to main content

objectiveai_sdk/cli/command/viewer/generate_secret_signature_pair/
mod.rs

1//! `viewer generate-secret-signature-pair` — 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.viewer.generate_secret_signature_pair.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub jq: Option<String>,
10}
11
12#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
13#[schemars(rename = "cli.command.viewer.generate_secret_signature_pair.Path")]
14pub enum Path {
15    #[serde(rename = "viewer/generate_secret_signature_pair")]
16    ViewerGenerateSecretSignaturePair,
17}
18impl CommandRequest for Request {
19    fn into_command(&self) -> Vec<String> {
20        let mut argv = vec!["viewer".to_string(), "generate-secret-signature-pair".to_string()];
21        if let Some(jq) = &self.jq {
22            argv.push("--jq".to_string());
23            argv.push(jq.clone());
24        }
25        argv
26    }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
30#[schemars(rename = "cli.command.viewer.generate_secret_signature_pair.Response")]
31pub struct Response {
32    pub secret: String,
33    pub signature: String,
34}
35
36#[derive(clap::Args)]
37pub struct Args {
38    /// jq filter applied to the JSON output.
39    #[arg(long)]
40    pub jq: Option<String>,
41}
42
43#[derive(clap::Args)]
44#[command(args_conflicts_with_subcommands = true)]
45pub struct Command {
46    #[command(flatten)]
47    pub args: Args,
48    #[command(subcommand)]
49    pub schema: Option<Schema>,
50}
51
52#[derive(clap::Subcommand)]
53pub enum Schema {
54    /// Emit the JSON Schema for this leaf's `Request` type and exit.
55    RequestSchema(request_schema::Args),
56    /// Emit the JSON Schema for this leaf's `Response` type and exit.
57    ResponseSchema(response_schema::Args),
58}
59
60impl TryFrom<Args> for Request {
61    type Error = crate::cli::command::FromArgsError;
62    fn try_from(args: Args) -> Result<Self, Self::Error> {
63        Ok(Self { path_type: Path::ViewerGenerateSecretSignaturePair, jq: args.jq })
64    }
65}
66
67#[cfg(feature = "cli-executor")]
68pub async fn execute<E: crate::cli::command::CommandExecutor>(
69    executor: &E,
70    mut request: Request,
71
72        agent_arguments: Option<&crate::cli::command::AgentArguments>,
73    ) -> Result<Response, E::Error> {
74    request.jq = None;
75    executor.execute_one(request, agent_arguments).await
76}
77
78#[cfg(feature = "cli-executor")]
79pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
80    executor: &E,
81    mut request: Request,
82    jq: String,
83
84        agent_arguments: Option<&crate::cli::command::AgentArguments>,
85    ) -> Result<serde_json::Value, E::Error> {
86    request.jq = Some(jq);
87    executor.execute_one(request, agent_arguments).await
88}
89
90#[cfg(feature = "mcp")]
91impl crate::cli::command::CommandResponse for Response {
92    fn into_mcp(self) -> crate::cli::command::McpResponseItem {
93        crate::cli::command::McpResponseItem::JSONL(serde_json::to_value(self).unwrap())
94    }
95}
96
97pub mod request_schema;
98
99pub mod response_schema;