Skip to main content

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