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