mirror of
https://github.com/RGBCube/dix
synced 2025-07-28 12:17:45 +00:00
src/main.rs: cleanup
This commit is contained in:
parent
9cd4befc31
commit
7ac9c287ec
1 changed files with 96 additions and 97 deletions
23
src/main.rs
23
src/main.rs
|
@ -27,10 +27,11 @@ struct Args {
|
||||||
closure_size: bool,
|
closure_size: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only there to make the compiler shut up for now.
|
struct Package<'a> {
|
||||||
#[derive(Debug)]
|
name: &'a str,
|
||||||
enum BlaErr {
|
versions: HashSet<&'a str>,
|
||||||
LolErr,
|
/// Save if a package is a dependency of another package
|
||||||
|
is_dep: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -57,7 +58,6 @@ fn main() {
|
||||||
let package_list_pre = get_packages(&args.path);
|
let package_list_pre = get_packages(&args.path);
|
||||||
let package_list_post = get_packages(&args.path2);
|
let package_list_post = get_packages(&args.path2);
|
||||||
|
|
||||||
if let (Ok(package_list_pre), Ok(package_list_post)) = (package_list_pre, package_list_post) {
|
|
||||||
// Map from packages of the first closure to their version
|
// Map from packages of the first closure to their version
|
||||||
|
|
||||||
let mut pre = HashMap::<&str, HashSet<&str>>::new();
|
let mut pre = HashMap::<&str, HashSet<&str>>::new();
|
||||||
|
@ -152,11 +152,10 @@ fn main() {
|
||||||
println!("After: {post_size} MiB");
|
println!("After: {post_size} MiB");
|
||||||
println!("Difference: {} MiB", post_size - pre_size);
|
println!("Difference: {} MiB", post_size - pre_size);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the packages in a closure
|
// gets the packages in a closure
|
||||||
fn get_packages(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
|
fn get_packages(path: &std::path::Path) -> Vec<String> {
|
||||||
// get the nix store paths using nix-store --query --references <path>
|
// get the nix store paths using nix-store --query --references <path>
|
||||||
let references = Command::new("nix-store")
|
let references = Command::new("nix-store")
|
||||||
.arg("--query")
|
.arg("--query")
|
||||||
|
@ -169,14 +168,14 @@ fn get_packages(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
|
||||||
|
|
||||||
if let Ok(list) = list {
|
if let Ok(list) = list {
|
||||||
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
|
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
|
||||||
return Ok(res);
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(BlaErr::LolErr)
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the dependencies of the packages in a closure
|
// gets the dependencies of the packages in a closure
|
||||||
fn get_dependencies(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
|
fn get_dependencies(path: &std::path::Path) -> Vec<String> {
|
||||||
// get the nix store paths using nix-store --query --references <path>
|
// get the nix store paths using nix-store --query --references <path>
|
||||||
let references = Command::new("nix-store")
|
let references = Command::new("nix-store")
|
||||||
.arg("--query")
|
.arg("--query")
|
||||||
|
@ -189,10 +188,10 @@ fn get_dependencies(path: &std::path::Path) -> Result<Vec<String>, BlaErr> {
|
||||||
|
|
||||||
if let Ok(list) = list {
|
if let Ok(list) = list {
|
||||||
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
|
let res: Vec<String> = list.lines().map(ToString::to_string).collect();
|
||||||
return Ok(res);
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(BlaErr::LolErr)
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_version<'a>(pack: impl Into<&'a str>) -> (&'a str, &'a str) {
|
fn get_version<'a>(pack: impl Into<&'a str>) -> (&'a str, &'a str) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue