git_x/
cli.rs

1use clap::Parser;
2
3#[derive(Parser)]
4pub struct Cli {
5    #[clap(subcommand)]
6    pub command: Commands,
7}
8
9#[derive(clap::Subcommand)]
10pub enum Commands {
11    #[clap(about = "Rename the current branch")]
12    RenameBranch {
13        #[clap(help = "New name for the current branch")]
14        new_name: String,
15    },
16    #[clap(about = "Delete merged local branches (except protected ones)")]
17    PruneBranches {
18        #[clap(
19            long = "except",
20            value_name = "branches",
21            help = "Comma-separated list of branches to exclude"
22        )]
23        except: Option<String>,
24    },
25    #[clap(about = "Show a high-level overview of the current repo")]
26    Info,
27    #[clap(about = "Pretty Git log with branches, remotes, and HEADs")]
28    Graph,
29    #[clap(about = "Colorized Git log with branches, remotes, and HEADs")]
30    ColorGraph,
31    #[clap(about = "Show commits since a reference (e.g., cb676ec, origin/main)")]
32    Since {
33        #[clap(help = "Reference point")]
34        reference: String,
35    },
36    #[clap(about = "Undo the last commit (without losing changes)")]
37    Undo,
38    #[clap(about = "Delete all fully merged local branches (except protected ones)")]
39    CleanBranches {
40        #[clap(long = "dry-run", help = "Prints the branches it would delete instead of actually deleting them", action = clap::ArgAction::SetTrue)]
41        dry_run: bool,
42    },
43    #[clap(about = "Show what’s different between this branch and another (default: main)")]
44    What {
45        #[clap(long = "target", help = "Branch to compare to")]
46        target: Option<String>,
47    },
48    #[clap(about = "Show a short, changelog-style summary of recent commits")]
49    Summary {
50        #[clap(
51            long = "since",
52            help = "Accepts flexible formats like \"yesterday\", \"3 days ago\", \"2025-07-01\", etc. (same as git log --since)"
53        )]
54        since: String,
55    },
56}
57
58// pub fn build_cli() -> Command {
59//     Command::new("git-x")
60//         .about("Supercharge your Git workflow")
61//         .version("0.1.0")
62//         .subcommand_required(true)
63//         .arg_required_else_help(true)
64//         .subcommand(
65//             Command::new("rename-branch")
66//                 .about("Rename the current branch")
67//                 .arg(Arg::new("new_name").help("New name for the current branch").required(true)),
68//         )
69//         .subcommand(
70//             Command::new("prune-branches")
71//                 .about("Delete local branches that have been merged")
72//                 .arg(
73//                     Arg::new("except")
74//                         .long("except")
75//                         .value_name("branches")
76//                         .help("Comma-separated list of branches to exclude")
77//                         .required(false),
78//                 ),
79//         )
80//         .subcommand(Command::new("info").about("Show a high-level summary of the repo"))
81//         .subcommand(Command::new("graph").about("Pretty Git log with branches, remotes, and HEADs"))
82//         .subcommand(
83//             Command::new("since")
84//                 .about("Show commits since a reference (e.g., 7ac9701, origin/main)")
85//                 .arg(Arg::new("reference").help("Reference point").required(true)),
86//         )
87//         .subcommand(Command::new("undo").about("Undo the last commit (without losing changes)"))
88//         .subcommand(
89//             Command::new("clean-branches")
90//                 .about("Delete all fully merged local branches (except protected ones)")
91//                 .arg(
92//                     Arg::new("dry_run")
93//                         .long("dry-run")
94//                         .help("Prints the branches it would delete instead of actually deleting them")
95//                         .action(clap::ArgAction::SetTrue),
96//                 ),
97//         )
98//         .subcommand(
99//             Command::new("what")
100//                 .about("Show what’s different between this branch and another (default: main)")
101//                 .arg(
102//                     Arg::new("target")
103//                         .long("target")
104//                         .help("Branch to compare to")
105//                         .required(false),
106//                 ),
107//         )
108//         .subcommand(
109//             Command::new("summary")
110//                 .about("Show a short, changelog-style summary of recent commits")
111//                 .arg(
112//                     Arg::new("since")
113//                         .long("since")
114//                         .help("Accepts flexible formats like \"yesterday\", \"3 days ago\", \"2025-07-01\", etc. (same as git log --since)")
115//                         .required(true),
116//                 ),
117//         )
118// }