objectiveai_cli/plugin_path.rs
1//! `PluginPath` — the `(owner, repository, version)` coordinate of the
2//! plugin a command is running on behalf of.
3//!
4//! Set on [`crate::context::Context::plugin`] when the CLI executes a
5//! command that originated from a plugin's bidirectional protocol. The
6//! three parts are threaded to nested-command subprocesses via the
7//! `OBJECTIVEAI_PLUGIN_OWNER` / `_REPOSITORY` / `_VERSION` env vars
8//! (see [`crate::spawn::apply_config_env`]).
9
10#[derive(Debug, Clone, PartialEq, Eq)]
11pub struct PluginPath {
12 pub owner: String,
13 pub repository: String,
14 pub version: String,
15}
16
17impl PluginPath {
18 /// Assemble a `PluginPath` from three optional parts. `Some` only
19 /// when all three are present; any missing part yields `None`.
20 pub fn from_parts(
21 owner: Option<String>,
22 repository: Option<String>,
23 version: Option<String>,
24 ) -> Option<Self> {
25 match (owner, repository, version) {
26 (Some(owner), Some(repository), Some(version)) => Some(Self {
27 owner,
28 repository,
29 version,
30 }),
31 _ => None,
32 }
33 }
34}