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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(
name = "ygg",
author,
version,
about = "✨ Yggdrasil CLI — the god-tree of your codebase.",
long_about = "Flatten your project into an AI-ready snapshot codex — index + contents in one command."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[command(flatten)]
pub args: Args, // your global flags stay the same
}
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Compare two sets of files (original vs modified)
Diff {
/// Source files or directories
#[arg(required = true)]
from: Vec<String>,
/// Target files or directories
#[arg(required = true)]
to: Vec<String>,
/// Align diff tags to a fixed column
#[arg(long)]
align_tags: bool,
},
}
#[derive(clap::Args, Debug)]
pub struct Args {
/// Root directory to scan
#[arg(default_value = ".")]
pub dir: String,
/// Show only files with these extensions (e.g. --show tex rs md)
#[arg(long, num_args = 0.., value_delimiter = ' ')]
pub show: Vec<String>,
/// Print file contents as well
#[arg(long)]
pub contents: bool,
/// Output in Markdown format
#[arg(long)]
pub md: bool,
/// Restrict output to these files/dirs/globs
#[arg(long, num_args = 1.., value_delimiter = ' ')]
pub only: Vec<String>,
/// Do not display line counts in file index
#[arg(long)]
pub no_lines: bool,
/// Provide inline patterns to ignore (globs, names, etc.)
#[arg(long, num_args = 1.., value_delimiter = ' ')]
pub ignore: Vec<String>,
/// Load blacklist patterns (like .gitignore) or enter manually.
#[arg(long, alias = "blacklist", num_args = 0..=1)]
pub black: Option<Option<String>>,
/// Load manifest (explicit file list to show) or enter manually.
#[arg(long, alias = "manifest", num_args = 0..=1)]
pub white: Option<Option<String>>,
/// Shortcut for `--white --contents --out SHOW.md[/NAME.md]`
/// Example: `ygg --whited summary.md`
#[arg(long, num_args = 0..=1)]
pub whited: Option<Option<String>>,
/// Write output to file instead of stdout
#[arg(long)]
pub out: Option<String>,
/// Align diff tags to a fixed column
#[arg(long)]
pub align_tags: bool,
}