Skip to main content

git_rewrite/
cli.rs

1use clap::Parser;
2
3#[derive(Parser)]
4#[command(name = "git rewrite", bin_name = "git rewrite")]
5#[command(author, version, about = "Rewrite Git repository history, trees, and blobs", long_about = None)]
6pub struct Cli {
7    #[command(subcommand)]
8    pub command: Command,
9}
10
11#[derive(clap::Subcommand)]
12pub enum Command {
13    /// Rewrite a Git tree, keeping only matching entries
14    Tree(TreeArgs),
15}
16
17#[derive(clap::Args)]
18pub struct TreeArgs {
19    /// Tree-ish reference (commit, branch, tag, or tree SHA) [default: HEAD]
20    #[arg(default_value = "HEAD")]
21    pub treeish: String,
22
23    /// Glob patterns for entries to keep in the tree (may be repeated)
24    #[arg(long = "only", required = true)]
25    pub patterns: Vec<String>,
26
27    /// Allow running with uncommitted changes in the working tree
28    #[arg(long)]
29    pub allow_dirty: bool,
30}