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
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
name = "drft",
version,
about = "Structural integrity checker for linked file systems"
)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
/// Run as if started in <path>
#[arg(short = 'C', global = true)]
pub directory: Option<PathBuf>,
/// Output format
#[arg(long, global = true, default_value = "text")]
pub format: OutputFormat,
/// Colorize output
#[arg(long, global = true, default_value = "auto")]
pub color: ColorChoice,
}
#[derive(Subcommand)]
pub enum Commands {
/// Create a drft.toml config file
Init,
/// Snapshot the current state to drft.lock
Lock {
/// Lock only this path and its outbound edges (default: lock the whole graph)
path: Option<String>,
},
/// Export the dependency graph as composed JGF
Graph {
/// Emit the raw set of per-graph fragments instead of the composed graph
#[arg(long)]
raw: bool,
},
/// List nodes transitively impacted by a change (default: stale sources)
Impact {
/// Paths to analyze (default: stale sources derived from the lockfile)
paths: Vec<String>,
/// Limit traversal to this many hops
#[arg(long)]
depth: Option<usize>,
/// Traversal direction
#[arg(long, default_value = "inbound")]
direction: Direction,
},
/// Check the composed graph against the lockfile for drift and structural findings
Check,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum OutputFormat {
Text,
Json,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum Direction {
Inbound,
Outbound,
Both,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum ColorChoice {
Auto,
Always,
Never,
}