git_conform/
cli.rs

1//! Setup and configuration of the command-line interface
2
3use clap::{Parser, Subcommand};
4
5/// Handles parsing of command-line arguments
6#[derive(Parser)]
7#[command(version, about, long_about = None)]
8#[command(propagate_version = true)]
9pub struct Cli {
10    #[command(subcommand)]
11    command: Commands
12}
13
14impl Cli {
15    #![allow(clippy::must_use_candidate)]
16    pub fn get_command(&self) -> &Commands {
17        &self.command
18    }
19}
20
21/// List of available commands and options
22#[derive(Subcommand)]
23pub enum Commands {
24    /// Search for untracked repositories
25    /// and add them for tracking
26    Scan {
27        /// Directories specified for scanning
28        #[arg(required = true, group = "directories")]
29        dirs: Vec<String>,
30        /// Scan all directories in your /home
31        #[arg(short, long, group = "directories")]
32        #[arg(default_value_t = false)]
33        all: bool,
34        /// Allow scanning hidden directories
35        #[arg(long)]
36        #[arg(default_value_t = false)]
37        hidden: bool
38    },
39    /// Print the list of tracked repositories
40    List,
41    /// Add specified repositories for tracking
42    Add {
43        #[arg(required = true)]
44        repos: Vec<String>
45    },
46    /// Remove specified repositories from tracking
47    Rm {
48        #[arg(required = true, group = "repositories")]
49        repos: Vec<String>,
50        /// Remove all repositories from tracking
51        #[arg(short, long, group = "repositories")]
52        #[arg(default_value_t = false)]
53        all: bool
54    },
55    /// Inspect specified repositories
56    Check {
57        #[arg(required = true, group = "repositories")]
58        repos: Vec<String>,
59        /// Inspect all tracked repositories
60        #[arg(short, long, group = "repositories")]
61        #[arg(default_value_t = false)]
62        all: bool,
63        /// Print only the output of `git status -s`
64        #[arg(short, long, group = "output")]
65        #[arg(default_value_t = false)]
66        status: bool,
67        /// Print only the ahead/behind commit metrics
68        #[arg(short, long, group = "output")]
69        #[arg(default_value_t = false)]
70        remotes: bool
71    }
72}