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        /// Print the list of ignored repositories instead
46        #[arg(short, long)]
47        #[arg(default_value_t = false)]
48        ignored: bool
49    },
50    /// Add specified repositories for tracking
51    Add {
52        #[arg(required = true)]
53        repos: Vec<String>
54    },
55    /// Remove specified repositories from tracking
56    Rm {
57        #[arg(required = true, group = "repositories")]
58        repos: Vec<String>,
59        /// Remove all repositories from tracking
60        #[arg(short, long, group = "repositories")]
61        #[arg(default_value_t = false)]
62        all: bool
63    },
64    /// Blacklist specified repositories from being added for tracking by the `scan` command
65    Ignore {
66        #[arg(required = true)]
67        repos: Vec<String>,
68    },
69    /// Remove specified repositories from the blacklist
70    Notice {
71        #[arg(required = true, group = "repositories")]
72        repos: Vec<String>,
73        /// Remove all repositories from the blacklist
74        #[arg(short, long, group = "repositories")]
75        #[arg(default_value_t = false)]
76        all: bool
77    },
78    /// Inspect specified repositories
79    Check {
80        #[arg(required = true, group = "repositories")]
81        repos: Vec<String>,
82        /// Inspect all tracked repositories
83        #[arg(short, long, group = "repositories")]
84        #[arg(default_value_t = false)]
85        all: bool,
86        /// Print only the output of `git status -s`
87        #[arg(short, long, group = "output")]
88        #[arg(default_value_t = false)]
89        status: bool,
90        /// Print only the differences between local repositories and their remotes
91        #[arg(short, long, group = "output")]
92        #[arg(default_value_t = false)]
93        remotes: bool
94    }
95}