|
|
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
|
|
#[macro_use] extern crate pin_project;
|
|
|
|
#[macro_use] extern crate lazy_static;
|
|
|
|
|
|
|
|
use color_eyre::{
|
|
|
|
eyre::{
|
|
|
|
self,
|
|
|
|
eyre,
|
|
|
|
|
|
|
|
WrapErr as _,
|
|
|
|
},
|
|
|
|
|
|
|
|
Help as _,
|
|
|
|
SectionExt as _,
|
|
|
|
};
|
|
|
|
|
|
|
|
#[macro_use] mod ext;
|
|
|
|
pub use ext::prelude::*;
|
|
|
|
|
|
|
|
mod data;
|
|
|
|
mod config;
|
|
|
|
mod state;
|
|
|
|
mod arg;
|
|
|
|
mod work;
|
|
|
|
|
|
|
|
async fn read_config() -> eyre::Result<config::Config>
|
|
|
|
{
|
|
|
|
match arg::parse_args().wrap_err(eyre!("Failed to parse args"))?
|
|
|
|
{
|
|
|
|
arg::Mode::Normal(cfg) => {
|
|
|
|
#[cfg(debug_assertions)] eprintln!("Parsed config: {:#?}\n", cfg);
|
|
|
|
Ok(cfg)
|
|
|
|
},
|
|
|
|
arg::Mode::Help => arg::help(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> eyre::Result<()> {
|
|
|
|
color_eyre::install()?;
|
|
|
|
|
|
|
|
let state = state::State::new(read_config().await
|
|
|
|
.wrap_err(eyre!("Failed to load config"))?
|
|
|
|
.validate()
|
|
|
|
.wrap_err(eyre!("Invalid config"))
|
|
|
|
.with_suggestion(|| "Try running `--help`")?);
|
|
|
|
|
|
|
|
let graph = work::work_on_all(state).await;
|
|
|
|
let mut graph = graph.into_hierarchical();
|
|
|
|
graph.compute_recursive_sizes();
|
|
|
|
|
|
|
|
println!("{:?}", graph);
|
|
|
|
/* let max_size = graph.directories().map(|x| x.size()).max();
|
|
|
|
println!("Max size: {:?}", max_size);*/
|
|
|
|
|
|
|
|
//println!("{:?}", graph);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|