|
1 | 1 | use crate::FilterTree; |
2 | | -use crate::cli::{FilterTreeArgs, OutputFormat}; |
3 | 2 | use git2 as git; |
4 | 3 |
|
| 4 | +/// Arguments for filtering a Git tree by glob patterns. |
| 5 | +/// |
| 6 | +/// Defined here so that the library exposes a self-contained type that |
| 7 | +/// downstream code can construct directly without going through the CLI. |
| 8 | +#[derive(clap::Args, Clone)] |
| 9 | +pub struct FilterTreeArgs { |
| 10 | + /// Tree-ish reference (commit, branch, tag, or tree SHA). |
| 11 | + pub treeish: String, |
| 12 | + |
| 13 | + /// Glob patterns for entries to keep in the tree. |
| 14 | + #[arg(required = true)] |
| 15 | + pub patterns: Vec<String>, |
| 16 | + |
| 17 | + /// Output format. |
| 18 | + #[arg(short, long, value_enum, default_value = "tree-sha")] |
| 19 | + pub format: OutputFormat, |
| 20 | +} |
| 21 | + |
| 22 | +/// Output format for [`print_tree`]. |
| 23 | +#[derive(Clone, Copy, Default, clap::ValueEnum)] |
| 24 | +pub enum OutputFormat { |
| 25 | + /// Print only the tree SHA (default). |
| 26 | + #[default] |
| 27 | + TreeSha, |
| 28 | + /// Print each entry's type and name. |
| 29 | + Entries, |
| 30 | + /// Print mode, type, OID, and name for every entry. |
| 31 | + Detailed, |
| 32 | +} |
| 33 | + |
5 | 34 | /// Core filter-tree operation: resolve the treeish, filter by patterns, and |
6 | 35 | /// return the OID of the resulting tree. This is the reusable building-block |
7 | 36 | /// that both the plumbing binary and the porcelain CLI can call. |
|
0 commit comments