ggen_cli_lib/cmds/mod.rs
1//! Command Router Module - clap-noun-verb v5.3.0 Migration
2//!
3//! This module provides the entry point for clap-noun-verb v5.3.0 with explicit verb registration.
4//! All noun modules with `#[verb("verb_name", "noun")]` functions are automatically discovered and registered.
5//!
6//! ## Architecture: Three-Layer Pattern
7//! ```text
8//! Layer 3 (CLI): cmds (router) -> explicit verb registration
9//! Layer 2 (Integration): auto-discovery -> #[verb] functions -> domain async logic
10//! Layer 1 (Domain): pure business logic
11//! ```
12
13// Shared helpers for command modules
14pub mod helpers;
15
16// Command modules - clap-noun-verb v5.3.0 explicit verb registration
17pub mod ai;
18pub mod ci;
19pub mod graph;
20// pub mod hook; // DISABLED: Deferred to v4.1.0 - Depends on marketplace-v2 feature
21pub mod marketplace; // ENABLED: marketplace-v2 CLI integration
22 // pub mod packs; // DISABLED: Deferred to v4.1.0 - Depends on marketplace-v2 feature
23pub mod ontology;
24pub mod project;
25pub mod template;
26#[cfg(feature = "test-quality")]
27pub mod test; // ENABLED: Feature 004 - Test quality audit and optimization
28pub mod utils; // ENABLED: FMEA (Failure Mode and Effects Analysis) utility commands
29pub mod workflow;
30
31use ggen_utils::error::Result;
32use serde_json::json;
33
34use crate::debug_log;
35
36/// Setup and run the command router using clap-noun-verb v3.4.0 auto-discovery
37pub fn run_cli() -> Result<()> {
38 // Handle --version flag before delegating to clap-noun-verb
39 let args: Vec<String> = std::env::args().collect();
40 // #region agent log
41 debug_log(
42 "H6",
43 "cmds/mod.rs:run_cli:entry",
44 "run_cli entry with args",
45 json!({ "args": args.clone() }),
46 );
47 // #endregion
48 if args.iter().any(|arg| arg == "--version" || arg == "-V") {
49 log::info!("ggen {}", env!("CARGO_PKG_VERSION"));
50 // #region agent log
51 debug_log(
52 "H6",
53 "cmds/mod.rs:run_cli:version",
54 "handled version flag",
55 json!({}),
56 );
57 // #endregion
58 return Ok(());
59 }
60
61 // Use clap-noun-verb's auto-discovery to find all [verb] functions
62 // #region agent log
63 debug_log(
64 "H7",
65 "cmds/mod.rs:run_cli:router",
66 "delegating to clap_noun_verb::run",
67 json!({}),
68 );
69 // #endregion
70 clap_noun_verb::run()
71 .map_err(|e| ggen_utils::error::Error::new(&format!("CLI execution failed: {}", e)))?;
72 // #region agent log
73 debug_log(
74 "H7",
75 "cmds/mod.rs:run_cli:router",
76 "clap_noun_verb::run completed",
77 json!({}),
78 );
79 // #endregion
80 Ok(())
81}