clap_noun_verb/cli/
mod.rs

1//! CLI layer - argument validation and routing only
2//!
3//! This module contains the CLI interface layer that validates arguments
4//! and delegates to business logic. It contains NO business logic.
5//!
6//! ## Design Principle
7//!
8//! CLI code ONLY validates arguments and options, then delegates to
9//! business logic functions. No business logic is allowed in this layer.
10
11pub mod builder;
12pub mod registry;
13pub mod router;
14pub mod validator;
15pub(crate) mod value_parser;
16
17pub use builder::CliBuilder;
18pub use registry::CommandRegistry;
19pub use router::CommandRouter;
20pub use validator::ArgValidator;
21
22/// Auto-run CLI with all registered commands
23///
24/// This function automatically discovers all functions marked with
25/// `#[noun]` and `#[verb]` attributes and runs the CLI.
26///
27/// These attribute macros are provided by the `clap-noun-verb-macros` crate.
28pub fn run() -> crate::error::Result<()> {
29    let registry = registry::CommandRegistry::get();
30    let registry = registry.lock().map_err(|e| {
31        crate::error::NounVerbError::execution_error(format!("Failed to lock registry: {}", e))
32    })?;
33    let args: Vec<String> = std::env::args().collect();
34    registry.run(args)
35}