git_rune/
cli.rs

1use crate::{commands, error::Result};
2use clap::{Parser, Subcommand};
3use std::path::PathBuf;
4
5#[derive(Parser)]
6#[command(author, version, about = "Git toolkit powered by LLMs")]
7pub struct Cli {
8    #[command(subcommand)]
9    command: Commands,
10}
11
12#[derive(Subcommand)]
13pub enum Commands {
14    /// Parse git repository into markdown
15    #[command(alias = "p")]
16    Parse {
17        /// Path to the directory to parse
18        #[arg(default_value = ".")]
19        path: Option<PathBuf>,
20
21        /// Directory where repo-structure.md will be written
22        #[arg(short, long)]
23        output_dir: Option<PathBuf>,
24
25        /// Comma-separated glob patterns to include
26        #[arg(short, long)]
27        include: Option<String>,
28
29        /// Comma-separated glob patterns to ignore
30        #[arg(short = 'x', long)]
31        ignore: Option<String>,
32    },
33}
34
35impl Cli {
36    pub async fn execute(self) -> Result<()> {
37        match self.command {
38            Commands::Parse {
39                path,
40                output_dir,
41                include,
42                ignore,
43            } => {
44                commands::parse::execute(path, output_dir, include, ignore).await?;
45            }
46        }
47        Ok(())
48    }
49}