Expand description
§metarepo-plugin-sdk
Author a metarepo external plugin by implementing one trait and calling
serve. The SDK owns the v1 stdio wire protocol — request framing,
parsing, dispatch, error handling, and the protocol-version handshake — so
plugin code never touches stdin/stdout or JSON directly.
use metarepo_plugin_sdk::{serve, CommandInfo, Plugin, RuntimeConfigDto};
struct Hello;
impl Plugin for Hello {
fn name(&self) -> &str { "hello" }
fn version(&self) -> &str { env!("CARGO_PKG_VERSION") }
fn commands(&self) -> Vec<CommandInfo> {
vec![CommandInfo::new("hello", "Print a greeting")]
}
fn handle(
&self,
_command: &str,
_args: &[String],
_config: &RuntimeConfigDto,
) -> anyhow::Result<Option<String>> {
Ok(Some("hello from a plugin".to_string()))
}
}
fn main() -> anyhow::Result<()> {
serve(Hello)
}Structs§
- ArgInfo
- Declarative description of a single command argument.
- Command
Info - Declarative description of a command (and its subcommands/args) that a plugin exposes. The host rebuilds clap commands from this over the wire.
- Runtime
Config Dto - Serializable snapshot of
RuntimeConfigpassed to a plugin over the wire.
Enums§
- Plugin
Request - A request sent from the host to a plugin subprocess.
- Plugin
Response - A response sent from a plugin subprocess back to the host.
Constants§
- PLUGIN_
PROTOCOL_ VERSION - Wire-format protocol version this build speaks. Plugins must report a
matching major version in their
PluginResponse::Infoor the host refuses to load them.