Skip to main content

clap_noun_verb_deploy/
lib.rs

1//! Deployment adapters for `clap-noun-verb` applications.
2//!
3//! `clap-noun-verb-deploy` projects one admitted CLI command graph into multiple
4//! serving and deployment surfaces without duplicating domain behavior.
5//!
6//! The crate deliberately separates three concerns:
7//! - **SELECT**: inspect the CLI graph and select a callable command.
8//! - **CONSTRUCT**: manufacture a validated [`Invocation`] or deployment manifest.
9//! - **DO**: execute only through an explicit [`Executor`] supplied by the caller.
10//!
11//! Kubernetes and OCI modules only render artifacts. They never contact a
12//! cluster, registry, container runtime, or network service.
13
14mod executor;
15mod gateway;
16mod policy;
17mod receipt;
18pub mod registry_executor;
19mod schema;
20
21#[cfg(feature = "container")]
22pub mod container;
23#[cfg(feature = "http")]
24pub mod http;
25#[cfg(feature = "kubernetes")]
26pub mod kubernetes;
27#[cfg(feature = "mcp")]
28pub mod mcp;
29#[cfg(feature = "container")]
30pub mod oci_builder;
31
32pub use executor::{Execution, Executor, Invocation, ProcessExecutionError, ProcessExecutor};
33pub use gateway::{Gateway, GatewayError};
34pub use policy::{
35    Admission, AdmissionError, AdmissionPolicy, AdmitValidated, CommandAllowList,
36    EnvironmentAllowList,
37};
38pub use receipt::{ExecutionRecord, ReplayError, ReplayVerification};
39pub use schema::{
40    ArgumentBehavior, ArgumentKind, ArgumentSchema, CliSchema, CommandSchema, InvocationBuildError,
41    ManifestError, ToolSchema,
42};
43
44use clap_noun_verb::CommandRegistry;
45
46/// Transport-neutral deployment projection of a `clap-noun-verb` registry.
47#[derive(Debug, Clone)]
48pub struct Deploy {
49    schema: CliSchema,
50}
51
52impl Deploy {
53    /// Project an existing registry into an immutable deployable schema.
54    ///
55    /// This operation is read-only and cannot execute a verb.
56    #[must_use]
57    pub fn from_registry(registry: &CommandRegistry) -> Self {
58        Self { schema: CliSchema::from_command(&registry.build_command()) }
59    }
60
61    /// Build a deployment projection from a raw Clap command graph.
62    #[must_use]
63    pub fn from_command(command: &clap_noun_verb::Command) -> Self {
64        Self { schema: CliSchema::from_command(command) }
65    }
66
67    /// Build a deployment projection directly from an already-obtained schema
68    /// (for example, one loaded from a manifest file via
69    /// [`CliSchema::from_manifest_path`] for a non-`clap-noun-verb` target).
70    #[must_use]
71    pub const fn from_schema(schema: CliSchema) -> Self {
72        Self { schema }
73    }
74
75    /// Return the immutable CLI schema shared by all transports.
76    #[must_use]
77    pub const fn schema(&self) -> &CliSchema {
78        &self.schema
79    }
80
81    /// Consume this projection and return its schema.
82    #[must_use]
83    pub fn into_schema(self) -> CliSchema {
84        self.schema
85    }
86}