1pub mod ai;
3pub mod audit;
4pub mod ci;
5pub mod doctor;
6pub mod graph;
7pub mod help_progressive;
8pub mod hook;
9pub mod lifecycle;
10pub mod market;
11pub mod project;
12pub mod shell;
13pub mod template;
14
15use clap::Subcommand;
16use ggen_utils::UtilsGgenConfig as GgenConfig;
17
18#[derive(Subcommand, Debug)]
19pub enum Commands {
20 #[command(name = "ai", about = "AI-powered template generation and analysis")]
21 Ai(ai::AiArgs),
22
23 #[command(name = "audit", about = "Security and performance auditing")]
24 Audit(audit::AuditCmd),
25
26 #[command(name = "ci", about = "CI/CD operations and GitHub integration")]
27 Ci(ci::CiCmd),
28
29 #[command(
30 name = "doctor",
31 about = "Check system prerequisites and environment health"
32 )]
33 Doctor(doctor::DoctorArgs),
34
35 #[command(name = "graph", about = "RDF graph operations")]
36 Graph(graph::GraphCmd),
37
38 #[command(
39 name = "help-me",
40 about = "Get personalized help based on your experience level"
41 )]
42 HelpProgressive(help_progressive::HelpProgressiveArgs),
43
44 #[command(
45 name = "hook",
46 about = "Knowledge hooks for autonomic graph regeneration"
47 )]
48 Hook(hook::HookCmd),
49
50 #[command(name = "lifecycle", about = "Universal lifecycle management")]
51 Lifecycle(lifecycle::LifecycleArgs),
52
53 #[command(name = "market", about = "Marketplace operations for gpacks")]
54 Market(market::MarketCmd),
55
56 #[command(name = "project", about = "Project scaffolding and generation")]
57 Project(project::ProjectCmd),
58
59 #[command(name = "shell", about = "Shell integration and completion")]
60 Shell(shell::ShellCmd),
61
62 #[command(name = "template", about = "Template management")]
63 Template(template::TemplateCmd),
64}
65
66impl Commands {
67 pub async fn run(&self) -> ggen_utils::error::Result<()> {
68 if let Err(e) = self.record_usage() {
70 eprintln!("Warning: Could not record command usage: {}", e);
71 }
72
73 match self {
74 Commands::Ai(args) => ai::run(args).await,
75 Commands::Audit(cmd) => cmd.run().await,
76 Commands::Ci(cmd) => cmd.run().await,
77 Commands::Doctor(args) => doctor::run(args).await,
78 Commands::Graph(cmd) => cmd.run().await,
79 Commands::HelpProgressive(args) => help_progressive::run(args).await,
80 Commands::Hook(cmd) => cmd.run().await,
81 Commands::Lifecycle(args) => lifecycle::run(args.clone()).await,
82 Commands::Market(cmd) => cmd.run().await,
83 Commands::Project(cmd) => cmd.run().await,
84 Commands::Shell(cmd) => cmd.run().await,
85 Commands::Template(cmd) => cmd.run().await,
86 }
87 }
88
89 fn record_usage(&self) -> Result<(), Box<dyn std::error::Error>> {
90 let command_name = match self {
91 Commands::Ai(_) => "ai",
92 Commands::Audit(_) => "audit",
93 Commands::Ci(_) => "ci",
94 Commands::Doctor(_) => "doctor",
95 Commands::Graph(_) => "graph",
96 Commands::HelpProgressive(_) => "help-me",
97 Commands::Hook(_) => "hook",
98 Commands::Lifecycle(_) => "lifecycle",
99 Commands::Market(_) => "market",
100 Commands::Project(_) => "project",
101 Commands::Shell(_) => "shell",
102 Commands::Template(_) => "template",
103 };
104
105 let mut activity = ggen_utils::user_level::UserActivity::load()?;
106 activity.record_command(command_name);
107 activity.save()?;
108
109 Ok(())
110 }
111
112 pub async fn run_with_config(
113 &self, _ggen_config: Option<GgenConfig>,
114 ) -> ggen_utils::error::Result<()> {
115 if let Err(e) = self.record_usage() {
117 eprintln!("Warning: Could not record command usage: {}", e);
118 }
119
120 match self {
121 Commands::Ai(args) => ai::run(args).await,
122 Commands::Audit(cmd) => cmd.run().await,
123 Commands::Ci(cmd) => cmd.run().await,
124 Commands::Doctor(args) => doctor::run(args).await,
125 Commands::Graph(cmd) => cmd.run().await,
126 Commands::HelpProgressive(args) => help_progressive::run(args).await,
127 Commands::Hook(cmd) => cmd.run().await,
128 Commands::Lifecycle(args) => lifecycle::run(args.clone()).await,
129 Commands::Market(cmd) => cmd.run().await,
130 Commands::Project(cmd) => cmd.run().await,
131 Commands::Shell(cmd) => cmd.run().await,
132 Commands::Template(cmd) => cmd.run().await,
133 }
134 }
135}