Skip to main content

objectiveai_sdk/cli/command/api/config/github_authorization/get/
mod.rs

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