Skip to main content

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        /// Suppress information messages
39        #[arg(short, long)]
40        #[arg(default_value_t = false)]
41        quiet: bool
42    },
43    /// Print the list of tracked repositories
44    List,
45    /// Add specified repositories for tracking
46    Add {
47        #[arg(required = true)]
48        repos: Vec<String>
49    },
50    /// Remove specified repositories from tracking
51    Rm {
52        #[arg(required = true, group = "repositories")]
53        repos: Vec<String>,
54        /// Remove all repositories from tracking
55        #[arg(short, long, group = "repositories")]
56        #[arg(default_value_t = false)]
57        all: bool
58    },
59    /// Inspect specified repositories
60    Check {
61        #[arg(required = true, group = "repositories")]
62        repos: Vec<String>,
63        /// Inspect all tracked repositories
64        #[arg(short, long, group = "repositories")]
65        #[arg(default_value_t = false)]
66        all: bool,
67        /// Print only the output of `git status -s`
68        #[arg(short, long, group = "output")]
69        #[arg(default_value_t = false)]
70        status: bool,
71        /// Print only the ahead/behind commit metrics
72        #[arg(short, long, group = "output")]
73        #[arg(default_value_t = false)]
74        remotes: bool
75    }
76}