1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "xgit")]
#[command(about = "A Git extension tool")]
#[command(version = env!("CARGO_PKG_VERSION"))]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Branch operations (alias: b)
#[command(alias = "b")]
Branch {
/// Clean up local branches that have been merged and deleted remotely
#[arg(long)]
prune_merged: bool,
/// Show current branch and associated GitHub PR information
#[arg(long)]
stats: bool,
/// Show what would be pruned without actually deleting branches
#[arg(long)]
dry_run: bool,
},
/// Create a commit (passthrough to git commit) (alias: c)
#[command(alias = "c")]
Commit {
/// Arguments to pass to git commit
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},
/// Sync local commit stack to GitHub stacked PRs
Diff {
/// Repair mapping by attaching a PR number to a commit SHA and resyncing
#[arg(long, value_names = ["PR_NUMBER", "COMMIT_SHA"], num_args = 2)]
repair: Option<Vec<String>>,
},
/// Explicit git passthrough command (e.g. xgit git diff)
Git {
/// Git arguments where first arg is the git subcommand
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
args: Vec<String>,
},
}