Skip to main content

objectiveai_sdk/cli/command/plugins/list/
mod.rs

1//! `plugins list` — 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.plugins.list.Request")]
7pub struct Request {
8    pub path_type: Path,
9    pub offset: Option<usize>,
10    pub limit: Option<usize>,
11    #[serde(flatten)]
12    pub base: crate::cli::command::RequestBase,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, schemars::JsonSchema)]
16#[schemars(rename = "cli.command.plugins.list.Path")]
17pub enum Path {
18    #[serde(rename = "plugins/list")]
19    PluginsList,
20}
21
22impl CommandRequest for Request {
23    fn into_command(&self) -> Vec<String> {
24        let mut argv = vec!["plugins".to_string(), "list".to_string()];
25        if let Some(offset) = self.offset {
26            argv.push("--offset".to_string());
27            argv.push(offset.to_string());
28        }
29        if let Some(limit) = self.limit {
30            argv.push("--limit".to_string());
31            argv.push(limit.to_string());
32        }
33        self.base.push_flags(&mut argv);
34        argv
35    }
36
37    fn request_base(&self) -> &crate::cli::command::RequestBase {
38        &self.base
39    }
40
41    fn request_base_mut(&mut self) -> Option<&mut crate::cli::command::RequestBase> {
42        Some(&mut self.base)
43    }
44}
45
46// Each list item carries the same shape as `plugins get`'s response —
47// `ResponseManifest` is the canonical definition. Re-export here so
48// list items deserialize as the same Rust type the bare-naked
49// dispatcher already constructs.
50pub use super::get::{
51    ResponseHttpMethod, ResponseManifest as ResponseItem, ResponseMcpServer,
52    ResponseViewerRoute,
53};
54
55#[derive(clap::Args)]
56pub struct Args {
57    /// Skip the first N matching entries.
58    #[arg(long)]
59    pub offset: Option<usize>,
60    /// Return at most N matching entries.
61    #[arg(long)]
62    pub limit: Option<usize>,
63    #[command(flatten)]
64    pub base: crate::cli::command::RequestBaseArgs,
65}
66
67#[derive(clap::Args)]
68#[command(args_conflicts_with_subcommands = true)]
69pub struct Command {
70    #[command(flatten)]
71    pub args: Args,
72    #[command(subcommand)]
73    pub schema: Option<Schema>,
74}
75
76#[derive(clap::Subcommand)]
77pub enum Schema {
78    /// Emit the JSON Schema for this leaf's `Request` type and exit.
79    RequestSchema(request_schema::Args),
80    /// Emit the JSON Schema for this leaf's `Response` type and exit.
81    ResponseSchema(response_schema::Args),
82}
83
84impl TryFrom<Args> for Request {
85    type Error = crate::cli::command::FromArgsError;
86    fn try_from(args: Args) -> Result<Self, Self::Error> {
87        Ok(Self { path_type: Path::PluginsList,
88            offset: args.offset,
89            limit: args.limit,
90            base: args.base.into(),
91        })
92    }
93}
94
95#[cfg(feature = "cli-executor")]
96pub async fn execute<E: crate::cli::command::CommandExecutor>(
97    executor: &E,
98    mut request: Request,
99
100        agent_arguments: Option<&crate::cli::command::AgentArguments>,
101    ) -> Result<E::Stream<ResponseItem>, E::Error> {
102    request.base.clear_transform();
103    executor.execute(request, agent_arguments).await
104}
105
106#[cfg(feature = "cli-executor")]
107pub async fn execute_transform<E: crate::cli::command::CommandExecutor>(
108    executor: &E,
109    mut request: Request,
110    transform: crate::cli::command::Transform,
111
112        agent_arguments: Option<&crate::cli::command::AgentArguments>,
113    ) -> Result<E::Stream<serde_json::Value>, E::Error> {
114    request.base.set_transform(transform);
115    executor.execute(request, agent_arguments).await
116}
117
118pub mod request_schema;
119
120
121pub mod response_schema;