1pub mod agent;
2pub mod analyzer;
3pub mod cli;
4pub mod common;
5pub mod config;
6pub mod error;
7pub mod generator;
8pub mod handlers;
9pub mod telemetry; pub use analyzer::{ProjectAnalysis, analyze_project};
13use cli::Commands;
14pub use error::{IaCGeneratorError, Result};
15pub use generator::{generate_compose, generate_dockerfile, generate_terraform};
16pub use handlers::*;
17pub use telemetry::{TelemetryClient, TelemetryConfig, UserId}; pub const VERSION: &str = env!("CARGO_PKG_VERSION");
21
22pub async fn run_command(command: Commands) -> Result<()> {
23 match command {
24 Commands::Analyze {
25 path,
26 json,
27 detailed,
28 display,
29 only,
30 color_scheme,
31 } => {
32 match handlers::handle_analyze(path, json, detailed, display, only, color_scheme) {
33 Ok(_output) => Ok(()), Err(e) => Err(e),
35 }
36 }
37 Commands::Generate {
38 path,
39 output,
40 dockerfile,
41 compose,
42 terraform,
43 all,
44 dry_run,
45 force,
46 } => handlers::handle_generate(
47 path, output, dockerfile, compose, terraform, all, dry_run, force,
48 ),
49 Commands::Validate { path, types, fix } => handlers::handle_validate(path, types, fix),
50 Commands::Support {
51 languages,
52 frameworks,
53 detailed,
54 } => handlers::handle_support(languages, frameworks, detailed),
55 Commands::Dependencies {
56 path,
57 licenses,
58 vulnerabilities,
59 prod_only,
60 dev_only,
61 format,
62 } => handlers::handle_dependencies(
63 path,
64 licenses,
65 vulnerabilities,
66 prod_only,
67 dev_only,
68 format,
69 )
70 .await
71 .map(|_| ()),
72 Commands::Vulnerabilities {
73 path,
74 severity,
75 format,
76 output,
77 } => handlers::handle_vulnerabilities(path, severity, format, output).await,
78 Commands::Security {
79 path,
80 mode,
81 include_low,
82 no_secrets,
83 no_code_patterns,
84 no_infrastructure,
85 no_compliance,
86 frameworks,
87 format,
88 output,
89 fail_on_findings,
90 } => {
91 handlers::handle_security(
92 path,
93 mode,
94 include_low,
95 no_secrets,
96 no_code_patterns,
97 no_infrastructure,
98 no_compliance,
99 frameworks,
100 format,
101 output,
102 fail_on_findings,
103 )
104 .map(|_| ()) }
106 Commands::Tools { command } => handlers::handle_tools(command).await,
107 Commands::Chat { path, provider, model, query } => {
108 use agent::ProviderType;
109 use cli::ChatProvider;
110
111 let project_path = path.canonicalize().unwrap_or(path);
112 let provider_type = match provider {
113 ChatProvider::Openai => ProviderType::OpenAI,
114 ChatProvider::Anthropic => ProviderType::Anthropic,
115 ChatProvider::Ollama => {
116 eprintln!("Ollama support coming soon. Using OpenAI as fallback.");
117 ProviderType::OpenAI
118 }
119 };
120
121 if let Some(q) = query {
122 let response = agent::run_query(&project_path, &q, provider_type, model).await?;
123 println!("{}", response);
124 Ok(())
125 } else {
126 agent::run_interactive(&project_path, provider_type, model).await?;
127 Ok(())
128 }
129 }
130 }
131}