Skip to content

Commit

Permalink
feat: changed some defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
massivebird committed Nov 29, 2024
1 parent 935e2c3 commit 8c6925c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/app/cli.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use clap::builder::{EnumValueParser, PossibleValue};
use clap::{Arg, ArgMatches, ValueEnum, ValueHint};

#[derive(Copy, Clone)]
#[derive(Default, Copy, Clone)]
pub enum OutputFmt {
Bullet,
#[default]
Line,
Bullet,
}

impl ValueEnum for OutputFmt {
Expand All @@ -27,8 +28,7 @@ pub(super) fn generate_matches() -> ArgMatches {
.long("output-fmt")
.short('o')
.value_parser(EnumValueParser::<OutputFmt>::new())
.help("Output format (default: \"bullet\")")
.default_value("bullet")
.help("Output format")
.value_name("format")
.value_hint(ValueHint::Other)
.required(false),
Expand Down
9 changes: 6 additions & 3 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod cli;
pub mod selected_tab;
pub mod site;

#[derive(Default)]
pub struct App {
pub sites: Arc<Mutex<Vec<Site>>>,
pub output_fmt: OutputFmt,
Expand All @@ -22,13 +23,15 @@ impl App {

let sites = Self::read_sites_from_file();

let output_fmt = *matches.get_one::<OutputFmt>("output_fmt").unwrap();
let output_fmt = match matches.get_one::<OutputFmt>("output_fmt") {
Some(&fmt) => fmt,
None => OutputFmt::default(),
};

Self {
sites: Arc::new(Mutex::new(sites)),
output_fmt,
selected_tab: SelectedTab::Live,
selected_chart_site_idx: 0,
..Default::default()
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/selected_tab.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use ratatui::text::Line;
use strum::{Display, EnumIter, FromRepr};

#[derive(Copy, Clone, Display, FromRepr, EnumIter, PartialEq, Eq)]
#[derive(Default, Copy, Clone, Display, FromRepr, EnumIter, PartialEq, Eq)]
pub enum SelectedTab {
#[default]
#[strum(to_string = "Live")]
Live,
#[strum(to_string = "Chart")]
Expand Down

0 comments on commit 8c6925c

Please sign in to comment.