Initial upload: GitPulse - Developer Productivity Analyzer CLI tool
Some checks failed
CI / test (push) Has been cancelled
CI / release (push) Has been cancelled

This commit is contained in:
2026-02-04 15:45:22 +00:00
parent 230f0d0e93
commit 1720305985

84
src/cli/mod.rs Normal file
View File

@@ -0,0 +1,84 @@
pub mod analyze;
pub mod dashboard;
pub mod export;
pub mod init;
use anyhow::{Context, Result};
use clap::{Parser, Subcommand};
use std::path::PathBuf;
use crate::commands::analyze::AnalyzeArgs;
use crate::commands::export::ExportArgs;
use crate::config::Config;
#[derive(Parser, Debug)]
#[command(name = "gitpulse")]
#[command(author, version, about, long_about = None)]
#[command(after_help = "For more information, visit https://github.com/gitpulse/gitpulse")]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(short, long, global = true, value_name = "PATH")]
#[arg(help = "Path to git repository (defaults to current directory)")]
pub repo: Option<PathBuf>,
#[arg(short, long, global = true)]
#[arg(help = "Enable verbose output")]
pub verbose: bool,
#[arg(short, long, global = true, value_name = "FILE")]
#[arg(help = "Path to configuration file")]
pub config: Option<PathBuf>,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
#[command(name = "analyze", alias = "a")]
#[command(about = "Analyze git repository and display statistics")]
#[command(long_about = "Analyze git repository and display commit frequency, code churn, contributor statistics, and more.")]
Analyze(AnalyzeArgs),
#[command(name = "dashboard", alias = "d")]
#[command(about = "Launch interactive terminal dashboard")]
#[command(long_about = "Launch an interactive terminal dashboard showing project health, commit trends, and contributor metrics.")]
Dashboard {},
#[command(name = "export", alias = "e")]
#[command(about = "Export analysis results to JSON or CSV")]
#[command(long_about = "Export analysis results to JSON or CSV format for external processing.")]
Export(ExportArgs),
#[command(name = "init")]
#[command(about = "Initialize gitpulse configuration")]
#[command(long_about = "Create a default configuration file in the appropriate location.")]
Init {},
#[command(name = "show-config")]
#[command(about = "Show current configuration")]
#[command(long_about = "Display the current configuration with all effective values.")]
ShowConfig {},
}
impl Cli {
pub fn run(self) -> Result<()> {
let config = Config::load(self.config.as_ref())?;
match self.command {
Commands::Analyze(args) => {
commands::analyze::run(self.repo, args, &config, self.verbose)
}
Commands::Dashboard {} => {
commands::dashboard::run(self.repo, &config, self.verbose)
}
Commands::Export(args) => {
commands::export::run(self.repo, args, &config, self.verbose)
}
Commands::Init {} => commands::init::run(&config),
Commands::ShowConfig {} => {
println!("{:#?}", config);
Ok(())
}
}
}
}