ai_code_buddy/
args.rs

1use clap::Parser;
2
3/// Check if GPU acceleration is available at compile time
4fn is_gpu_available() -> bool {
5    #[cfg(gpu_available)]
6    {
7        true
8    }
9    #[cfg(not(gpu_available))]
10    {
11        false
12    }
13}
14
15#[derive(Parser, Clone, Debug, Resource)]
16#[command(
17    name = "ai-code-buddy",
18    version,
19    about = "🤖 AI-powered code review tool with elegant TUI",
20    long_about = "AI Code Buddy is an intelligent code analysis tool that compares branches, \
21                  detects security vulnerabilities, performance issues, and code quality problems. \
22                  Features a modern Bevy-powered TUI with real-time analysis and reporting."
23)]
24pub struct Args {
25    /// Git repository path to analyze
26    #[arg(
27        value_name = "REPO_PATH",
28        default_value = ".",
29        help = "Path to the Git repository (default: current directory)"
30    )]
31    pub repo_path: String,
32
33    /// Source branch for comparison
34    #[arg(
35        short = 's',
36        long = "source",
37        value_name = "BRANCH",
38        default_value = "main",
39        help = "Source branch to compare from"
40    )]
41    pub source_branch: String,
42
43    /// Target branch for comparison
44    #[arg(
45        short = 't',
46        long = "target",
47        value_name = "BRANCH",
48        default_value = "HEAD",
49        help = "Target branch to compare to (default: HEAD)"
50    )]
51    pub target_branch: String,
52
53    /// Use CLI mode instead of interactive TUI
54    #[arg(
55        long = "cli",
56        help = "Run in CLI mode with text output instead of interactive interface"
57    )]
58    pub cli_mode: bool,
59
60    /// Enable verbose output
61    #[arg(
62        short = 'v',
63        long = "verbose",
64        help = "Enable verbose output for debugging"
65    )]
66    pub verbose: bool,
67
68    /// Show credits and contributors
69    #[arg(
70        long = "credits",
71        help = "Show credits and list all contributors to the project"
72    )]
73    pub show_credits: bool,
74
75    /// Output format for results
76    #[arg(
77        short = 'f',
78        long = "format",
79        value_enum,
80        default_value = "summary",
81        help = "Output format for results"
82    )]
83    pub output_format: OutputFormat,
84
85    /// Exclude files matching pattern
86    #[arg(
87        long = "exclude",
88        value_name = "PATTERN",
89        help = "Exclude files matching glob pattern (can be used multiple times)",
90        action = clap::ArgAction::Append
91    )]
92    pub exclude_patterns: Vec<String>,
93
94    /// Include only files matching pattern
95    #[arg(
96        long = "include",
97        value_name = "PATTERN",
98        help = "Include only files matching glob pattern (can be used multiple times)",
99        action = clap::ArgAction::Append
100    )]
101    pub include_patterns: Vec<String>,
102
103    /// Enable GPU acceleration for AI analysis
104    #[arg(
105        long = "gpu",
106        help = "Enable GPU acceleration (Metal on Apple, CUDA on NVIDIA, auto-detected)",
107        default_value_t = is_gpu_available()
108    )]
109    pub use_gpu: bool,
110
111    /// Force CPU mode (disable GPU acceleration)
112    #[arg(
113        long = "cpu",
114        help = "Force CPU mode (disable GPU acceleration even if available)",
115        conflicts_with = "use_gpu"
116    )]
117    pub force_cpu: bool,
118
119    /// Enable parallel file analysis using Rayon
120    #[arg(
121        long = "parallel",
122        help = "Enable parallel file analysis using all available CPU cores",
123        default_value = "true"
124    )]
125    pub parallel: bool,
126
127    /// Disable AI inference (experimental)
128    #[arg(
129        long = "disable-ai",
130        help = "Disable AI-powered analysis (experimental feature)",
131        default_value_t = false
132    )]
133    pub disable_ai: bool,
134}
135
136#[derive(clap::ValueEnum, Clone, Debug, PartialEq)]
137pub enum OutputFormat {
138    /// Summary output with key findings
139    Summary,
140    /// Detailed output with all issues
141    Detailed,
142    /// JSON format for programmatic use
143    Json,
144    /// Markdown format for documentation
145    Markdown,
146}
147
148use bevy::prelude::Resource;