tangled
alpha
login
or
join now
tgirl.cloud
/
lix-diff
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
feat: use paths so we can check if they exist first
isabelroses.com
10 months ago
62d62425
b87f17fe
+19
-10
1 changed file
expand all
collapse all
unified
split
src
main.rs
+19
-10
src/main.rs
···
1
1
-
use std::env;
1
1
+
use std::{env, path::PathBuf};
2
2
3
3
use argh::FromArgs;
4
4
use color_eyre::Result;
···
21
21
22
22
/// the generation we are switching from
23
23
#[argh(positional)]
24
24
-
before: String,
24
24
+
before: PathBuf,
25
25
26
26
/// the generation we are switching to
27
27
-
#[argh(positional, default = "String::from(\"/run/current-system/\")")]
28
28
-
after: String,
27
27
+
#[argh(positional, default = "PathBuf::from(\"/run/current-system/\")")]
28
28
+
after: PathBuf,
29
29
}
30
30
31
31
fn main() -> Result<()> {
···
42
42
}
43
43
}
44
44
45
45
-
// Check if the generations are valid
46
46
-
if before.is_empty() || after.is_empty() {
47
47
-
eprintln!("Both generations must be specified.");
45
45
+
if !before.exists() {
46
46
+
eprintln!("Before generation does not exist: {}", before.display());
47
47
+
std::process::exit(1);
48
48
+
}
49
49
+
50
50
+
if !after.exists() {
51
51
+
eprintln!("After generation does not exist: {}", after.display());
48
52
std::process::exit(1);
49
53
}
50
54
51
51
-
let packages: PackageListDiff = DiffRoot::new(&before, &after)?.into();
55
55
+
let before_str = before
56
56
+
.to_str()
57
57
+
.expect("could not convert before path to str");
58
58
+
let after_str = after.to_str().expect("could not convert after path to str");
59
59
+
60
60
+
let packages: PackageListDiff = DiffRoot::new(before_str, after_str)?.into();
52
61
53
62
let arrow_style = Style::new().bold().fg(Color::LightGray);
54
63
55
55
-
let before_text = format!("<<< {before}");
56
56
-
let after_text = format!(">>> {after}");
64
64
+
let before_text = format!("<<< {before_str}");
65
65
+
let after_text = format!(">>> {after_str}");
57
66
58
67
println!("{}", arrow_style.paint(before_text));
59
68
println!("{}\n", arrow_style.paint(after_text));