objectiveai_sdk/cli/command/plugins/list/
mod.rs1use crate::cli::command::CommandRequest;
4
5#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
6#[schemars(rename = "cli.command.plugins.list.Request")]
7pub struct Request {
8 pub path_type: Path,
9 pub offset: Option<usize>,
10 pub limit: Option<usize>,
11 pub jq: Option<String>,
12}
13
14#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
15#[schemars(rename = "cli.command.plugins.list.Path")]
16pub enum Path {
17 #[serde(rename = "plugins/list")]
18 PluginsList,
19}
20
21impl CommandRequest for Request {
22 fn into_command(&self) -> Vec<String> {
23 let mut argv = vec!["plugins".to_string(), "list".to_string()];
24 if let Some(offset) = self.offset {
25 argv.push("--offset".to_string());
26 argv.push(offset.to_string());
27 }
28 if let Some(limit) = self.limit {
29 argv.push("--limit".to_string());
30 argv.push(limit.to_string());
31 }
32 if let Some(jq) = &self.jq {
33 argv.push("--jq".to_string());
34 argv.push(jq.clone());
35 }
36 argv
37 }
38}
39
40pub use super::get::{
45 ResponseBinaries, ResponseHttpMethod, ResponseManifest as ResponseItem,
46 ResponseMcpServer, ResponseViewerRoute,
47};
48
49#[derive(clap::Args)]
50pub struct Args {
51 #[arg(long)]
53 pub offset: Option<usize>,
54 #[arg(long)]
56 pub limit: Option<usize>,
57 #[arg(long)]
59 pub jq: Option<String>,
60}
61
62#[derive(clap::Args)]
63#[command(args_conflicts_with_subcommands = true)]
64pub struct Command {
65 #[command(flatten)]
66 pub args: Args,
67 #[command(subcommand)]
68 pub schema: Option<Schema>,
69}
70
71#[derive(clap::Subcommand)]
72pub enum Schema {
73 RequestSchema(request_schema::Args),
75 ResponseSchema(response_schema::Args),
77}
78
79impl TryFrom<Args> for Request {
80 type Error = crate::cli::command::FromArgsError;
81 fn try_from(args: Args) -> Result<Self, Self::Error> {
82 Ok(Self { path_type: Path::PluginsList,
83 offset: args.offset,
84 limit: args.limit,
85 jq: args.jq,
86 })
87 }
88}
89
90#[cfg(feature = "cli-executor")]
91pub async fn execute<E: crate::cli::command::CommandExecutor>(
92 executor: &E,
93 mut request: Request,
94
95 agent_arguments: Option<&crate::cli::command::AgentArguments>,
96 ) -> Result<E::Stream<ResponseItem>, E::Error> {
97 request.jq = None;
98 executor.execute(request, agent_arguments).await
99}
100
101#[cfg(feature = "cli-executor")]
102pub async fn execute_jq<E: crate::cli::command::CommandExecutor>(
103 executor: &E,
104 mut request: Request,
105 jq: String,
106
107 agent_arguments: Option<&crate::cli::command::AgentArguments>,
108 ) -> Result<E::Stream<serde_json::Value>, E::Error> {
109 request.jq = Some(jq);
110 executor.execute(request, agent_arguments).await
111}
112
113pub mod request_schema;
114
115
116pub mod response_schema;