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
17// New in v5.0 - Enhanced help system for improved usability
18pub mod discovery;
19pub mod examples;
20pub mod help;
21pub mod interactive;
22
23pub use builder::CliBuilder;
24pub use registry::CommandRegistry;
25pub use router::CommandRouter;
26pub use validator::ArgValidator;
27
28// Re-export help system components
29pub use discovery::{CommandDiscovery, SearchResult};
30pub use examples::{Example, ExamplesRegistry};
31pub use help::{CommandCategory, CommandInfo, HelpSystem};
32pub use interactive::{InteractiveHelp, InteractiveOutput};
33
34/// Auto-run CLI with all registered commands
35///
36/// This function automatically discovers all functions marked with
37/// `#[noun]` and `#[verb]` attributes and runs the CLI.
38///
39/// These attribute macros are provided by the `clap-noun-verb-macros` crate.
40pub fn run() -> crate::error::Result<()> {
41    let registry = registry::CommandRegistry::get();
42    let registry = registry.lock().map_err(|e| {
43        crate::error::NounVerbError::execution_error(format!("Failed to lock registry: {}", e))
44    })?;
45    let args: Vec<String> = std::env::args().collect();
46    registry.run(args)
47}