objectiveai_sdk/cli/command/plugins/install/github/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.plugins.install.github.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub owner: String,
10 pub repository: String,
11 pub commit_sha: Option<String>,
12 pub allow_untrusted: bool,
13 #[serde(flatten)]
14 pub base: crate::cli::command::RequestBase,
15}
16
17#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
18#[schemars(rename = "cli.command.plugins.install.github.Path")]
19pub enum Path {
20 #[serde(rename = "plugins/install/github")]
21 PluginsInstallGithub,
22}
23
24impl CommandRequest for Request {
25 fn request_base(&self) -> &crate::cli::command::RequestBase {
26 &self.base
27 }
28
29 fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
30 Some(&mut self.base)
31 }
32}
33
34#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
35#[schemars(rename = "cli.command.plugins.install.github.Response")]
36pub struct Response {
37 pub installed: bool,
38}
39
40#[derive(clap::Args)]
41#[command(group(clap::ArgGroup::new("owner_required").required(true).args(["owner"])))]
42#[command(group(clap::ArgGroup::new("repository_required").required(true).args(["repository"])))]
43pub struct Args {
44 #[arg(long)]
46 pub owner: Option<String>,
47 #[arg(long)]
49 pub repository: Option<String>,
50 #[arg(long)]
52 pub commit_sha: Option<String>,
53 #[arg(long)]
55 pub allow_untrusted: 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 Ok(Self { path_type: Path::PluginsInstallGithub,
81 owner: args.owner.ok_or_else(|| {
82 crate::cli::command::FromArgsError::path_parse(
83 "owner",
84 "--owner is required".to_string(),
85 )
86 })?,
87 repository: args.repository.ok_or_else(|| {
88 crate::cli::command::FromArgsError::path_parse(
89 "repository",
90 "--repository is required".to_string(),
91 )
92 })?,
93 commit_sha: args.commit_sha,
94 allow_untrusted: args.allow_untrusted,
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;