syncable_cli/
lib.rs

1//! # Syncable IaC CLI
2//!
3//! A Rust-based command-line application that analyzes code repositories and automatically
4//! generates Infrastructure as Code configurations including Dockerfiles, Docker Compose
5//! files, and Terraform configurations.
6//!
7//! ## Features
8//!
9//! - **Language Detection**: Automatically detects programming languages and their versions
10//! - **Framework Analysis**: Identifies frameworks and libraries used in the project
11//! - **Smart Generation**: Creates optimized IaC configurations based on project analysis
12//! - **Multiple Formats**: Supports Docker, Docker Compose, and Terraform generation
13//! - **Security-First**: Generates secure configurations following best practices
14//!
15//! ## Example
16//!
17//! ```rust,no_run
18//! use syncable_cli::{analyze_project, generate_dockerfile};
19//! use std::path::Path;
20//!
21//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
22//! let project_path = Path::new("./my-project");
23//! let analysis = analyze_project(project_path)?;
24//! let dockerfile = generate_dockerfile(&analysis)?;
25//! println!("{}", dockerfile);
26//! # Ok(())
27//! # }
28//! ```
29
30pub mod analyzer;
31pub mod cli;
32pub mod common;
33pub mod config;
34pub mod error;
35pub mod generator;
36pub mod handlers;
37
38// Re-export commonly used types and functions
39pub use analyzer::{analyze_project, ProjectAnalysis};
40pub use error::{IaCGeneratorError, Result};
41pub use generator::{generate_dockerfile, generate_compose, generate_terraform};
42pub use handlers::*;
43use cli::Commands;
44
45/// The current version of the CLI tool
46pub const VERSION: &str = env!("CARGO_PKG_VERSION");
47
48pub async fn run_command(command: Commands) -> Result<()> {
49    match command {
50        Commands::Analyze { path, json, detailed, display, only } => {
51            handlers::handle_analyze(path, json, detailed, display, only)
52        }
53        Commands::Generate {
54            path,
55            output,
56            dockerfile,
57            compose,
58            terraform,
59            all,
60            dry_run,
61            force
62        } => {
63            handlers::handle_generate(path, output, dockerfile, compose, terraform, all, dry_run, force)
64        }
65        Commands::Validate { path, types, fix } => {
66            handlers::handle_validate(path, types, fix)
67        }
68        Commands::Support { languages, frameworks, detailed } => {
69            handlers::handle_support(languages, frameworks, detailed)
70        }
71        Commands::Dependencies { path, licenses, vulnerabilities, prod_only, dev_only, format } => {
72            handlers::handle_dependencies(path, licenses, vulnerabilities, prod_only, dev_only, format).await
73        }
74        Commands::Vulnerabilities { path, severity, format, output } => {
75            handlers::handle_vulnerabilities(path, severity, format, output).await
76        }
77        Commands::Security {
78            path,
79            mode,
80            include_low,
81            no_secrets,
82            no_code_patterns,
83            no_infrastructure,
84            no_compliance,
85            frameworks,
86            format,
87            output,
88            fail_on_findings
89        } => {
90            handlers::handle_security(
91                path,
92                mode,
93                include_low,
94                no_secrets,
95                no_code_patterns,
96                no_infrastructure,
97                no_compliance,
98                frameworks,
99                format,
100                output,
101                fail_on_findings
102            )
103        }
104        Commands::Tools { command } => {
105            handlers::handle_tools(command).await
106        }
107    }
108}