You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dirstat/src/main.rs

66 lines
1.4 KiB

#![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);
println!("Max size file: {:?}", graph.path_max_size_for(data::FsKind::File));
println!("Max size dir: {:?}", graph.path_max_size_for(data::FsKind::Directory));
println!("Max size all: {:?}", graph.path_max_size());
/* let max_size = graph.directories().map(|x| x.size()).max();
println!("Max size: {:?}", max_size);*/
//println!("{:?}", graph);
Ok(())
}