This commit is contained in:
162
src/cli/mod.rs
Normal file
162
src/cli/mod.rs
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
use clap::{Parser, Subcommand, ValueEnum};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(name = "techdebt-tracker")]
|
||||||
|
#[command(author = "TechDebt Tracker Contributors")]
|
||||||
|
#[command(version = "0.1.0")]
|
||||||
|
#[command(about = "Track and analyze technical debt in your codebase", long_about = None)]
|
||||||
|
pub struct Args {
|
||||||
|
#[arg(short, long, global = true)]
|
||||||
|
pub config: Option<PathBuf>,
|
||||||
|
#[command(subcommand)]
|
||||||
|
pub command: Commands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand, Debug)]
|
||||||
|
pub enum Commands {
|
||||||
|
#[command(about = "Analyze codebase and show summary")]
|
||||||
|
Analyze(AnalyzeArgs),
|
||||||
|
#[command(about = "Open interactive TUI dashboard")]
|
||||||
|
Tui(TuiArgs),
|
||||||
|
#[command(about = "Export analysis to file")]
|
||||||
|
Export(ExportArgs),
|
||||||
|
#[command(about = "Initialize default configuration")]
|
||||||
|
Init(InitArgs),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Args, Debug)]
|
||||||
|
pub struct AnalyzeArgs {
|
||||||
|
#[arg(short, long, default_value = ".")]
|
||||||
|
pub path: PathBuf,
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub output: Option<PathBuf>,
|
||||||
|
#[arg(short, long, action)]
|
||||||
|
pub verbose: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Args, Debug)]
|
||||||
|
pub struct TuiArgs {
|
||||||
|
#[arg(short, long, default_value = ".")]
|
||||||
|
pub path: PathBuf,
|
||||||
|
#[arg(short, long, action)]
|
||||||
|
pub verbose: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Args, Debug)]
|
||||||
|
pub struct ExportArgs {
|
||||||
|
#[arg(short, long, default_value = ".")]
|
||||||
|
pub path: PathBuf,
|
||||||
|
#[arg(short, long)]
|
||||||
|
pub output: PathBuf,
|
||||||
|
#[arg(short, long, value_enum)]
|
||||||
|
pub format: ExportFormat,
|
||||||
|
#[arg(long)]
|
||||||
|
pub group_by: Option<GroupBy>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, ValueEnum)]
|
||||||
|
pub enum ExportFormat {
|
||||||
|
Json,
|
||||||
|
Markdown,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, ValueEnum)]
|
||||||
|
pub enum GroupBy {
|
||||||
|
File,
|
||||||
|
Priority,
|
||||||
|
Type,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Args, Debug)]
|
||||||
|
pub struct InitArgs {
|
||||||
|
#[arg(short, long, default_value = ".")]
|
||||||
|
pub path: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_config(path: &PathBuf) -> anyhow::Result<()> {
|
||||||
|
let config_content = r#"# TechDebt Tracker Configuration
|
||||||
|
|
||||||
|
# Comment patterns to search for
|
||||||
|
patterns:
|
||||||
|
- keyword: "FIXME"
|
||||||
|
priority: critical
|
||||||
|
regex: false
|
||||||
|
- keyword: "TODO"
|
||||||
|
priority: medium
|
||||||
|
regex: false
|
||||||
|
- keyword: "HACK"
|
||||||
|
priority: low
|
||||||
|
regex: false
|
||||||
|
- keyword: "BUG"
|
||||||
|
priority: high
|
||||||
|
regex: false
|
||||||
|
- keyword: "XXX"
|
||||||
|
priority: high
|
||||||
|
regex: false
|
||||||
|
- keyword: "NOTE"
|
||||||
|
priority: low
|
||||||
|
regex: false
|
||||||
|
|
||||||
|
# Languages to analyze
|
||||||
|
languages:
|
||||||
|
- javascript
|
||||||
|
- typescript
|
||||||
|
- python
|
||||||
|
- rust
|
||||||
|
- go
|
||||||
|
- java
|
||||||
|
- c
|
||||||
|
- cpp
|
||||||
|
- ruby
|
||||||
|
|
||||||
|
# Directories and files to ignore
|
||||||
|
ignore:
|
||||||
|
- "node_modules/**"
|
||||||
|
- "target/**"
|
||||||
|
- ".git/**"
|
||||||
|
- "vendor/**"
|
||||||
|
- "dist/**"
|
||||||
|
- "build/**"
|
||||||
|
- "*.min.js"
|
||||||
|
- "*.min.css"
|
||||||
|
- "*.pyc"
|
||||||
|
- "__pycache__/**"
|
||||||
|
|
||||||
|
# File extensions to include
|
||||||
|
extensions:
|
||||||
|
- ".js"
|
||||||
|
- ".ts"
|
||||||
|
- ".jsx"
|
||||||
|
- ".tsx"
|
||||||
|
- ".py"
|
||||||
|
- ".rs"
|
||||||
|
- ".go"
|
||||||
|
- ".java"
|
||||||
|
- ".c"
|
||||||
|
- ".cpp"
|
||||||
|
- ".h"
|
||||||
|
- ".hpp"
|
||||||
|
- ".rb"
|
||||||
|
- ".md"
|
||||||
|
- ".yml"
|
||||||
|
- ".yaml"
|
||||||
|
|
||||||
|
# Complexity analysis settings
|
||||||
|
complexity:
|
||||||
|
enabled: true
|
||||||
|
max_comment_length: 500
|
||||||
|
question_weight: 2
|
||||||
|
exclamation_weight: 1
|
||||||
|
|
||||||
|
# Export settings
|
||||||
|
export:
|
||||||
|
include_metadata: true
|
||||||
|
include_context: true
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let config_path = path.join("techdebt.yaml");
|
||||||
|
std::fs::write(&config_path, config_content)?;
|
||||||
|
println!("Created configuration file: {}", config_path.display());
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user