Add graceful error handling to df script

This commit is contained in:
2021-04-11 15:04:58 +02:00
parent 4becee4a89
commit f09c914881
6 changed files with 188 additions and 58 deletions

View File

@ -2,15 +2,16 @@
extern crate log;
mod builder;
mod error;
mod linker;
use builder::build_tree;
use error::Errors;
use linker::link_tree;
use log::LevelFilter;
use std::env;
use std::path::PathBuf;
use structopt::StructOpt;
use tokio::io;
#[derive(StructOpt)]
struct Opt {
@ -45,7 +46,14 @@ pub enum ColorMode {
}
#[tokio::main]
async fn main() -> io::Result<()> {
async fn main() {
match run().await {
Ok(_) => {}
Err(errors) => errors.log(),
}
}
async fn run() -> Result<(), Errors> {
let opt = Opt::from_args();
let filter_level = match opt.verbosity {