diff --git a/src/main.rs b/src/main.rs index 2fb15ac..afec1ae 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,15 +1,14 @@ -use structopt::StructOpt; +use app::UI; +use core::time; use std::time::{SystemTime, UNIX_EPOCH}; +use structopt::StructOpt; use termion::async_stdin; use termion::input::TermRead; -use app::UI; -use core::time; - mod app; mod plotting_utils; -mod widget_progress_bar; mod widget_main_chart; +mod widget_progress_bar; mod widget_text_output; static ONE_BILLION: f32 = 1000000000.0; @@ -22,11 +21,15 @@ struct Cli { #[structopt(short = "t", long = "target")] target_result: Option, - #[structopt(long = "show-regression-line")] - show_regression_line: Option, + #[structopt( + long = "show-regression-line", + parse(try_from_str), + default_value = "true" + )] + show_regression_line: bool, #[structopt(long = "show-target-line")] - show_target_line: Option, + show_target_line: bool, #[structopt(short = "l", long = "history-len", default_value = "100")] history_len: usize, @@ -42,20 +45,23 @@ fn main() { &args.command, args.target_result, args.history_len, - args.show_regression_line.or(Some(true)).unwrap(), - args.show_target_line.or(Some(false)).unwrap() + args.show_regression_line, + args.show_target_line, ); let mut keys = async_stdin().keys(); - loop{ - let current_time = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs_f64(); + loop { + let current_time = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap() + .as_secs_f64(); if refresh_rate.as_secs_f64() < current_time - last_time { ui.evaluate(); last_time = current_time; } if !ui.event_handler(keys.next()) { ui.clean_up_terminal(); - break + break; } - } -} \ No newline at end of file + } +}