diff --git a/src/args.rs b/src/args.rs index efc3438f..25435af3 100644 --- a/src/args.rs +++ b/src/args.rs @@ -6,9 +6,10 @@ use super::config::{config_dir_exists, init_config}; use super::daemon; use super::daemon::daemon_init; use super::display::show_config; +use super::graph::{get_graph_type, GraphType}; use super::interactive::interactive; use super::interface::{DaemonControl, DaemonController, Get, Getter, Interface, Set, Setter}; -use super::settings::{get_graph_type, GraphType, Settings}; +use super::settings::Settings; use super::warn_user; #[derive(StructOpt)] diff --git a/src/daemon.rs b/src/daemon.rs index 65427492..45cc53ba 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -38,14 +38,14 @@ use serde::Serialize; use super::config::Config; use super::cpu::{Speed, CPU}; -use super::graph::{Graph, Grapher}; +use super::graph::{Graph, GraphType, Grapher}; use super::logger; use super::logger::Interface; use super::network::{hook, listen}; use super::power::battery::{has_battery, Battery}; use super::power::lid::{Lid, LidRetriever, LidState}; use super::power::{Power, PowerRetriever}; -use super::settings::{GraphType, Settings}; +use super::settings::Settings; use super::setup::{inside_docker_message, inside_wsl_message}; use super::system::{ check_available_governors, check_cpu_freq, check_cpu_temperature, check_cpu_usage, diff --git a/src/graph.rs b/src/graph.rs index 9b8525cc..656c3318 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -1,4 +1,5 @@ use rasciigraph::{plot, Config}; +use std::fmt; pub trait Grapher { fn update_all(&mut self); @@ -34,3 +35,35 @@ impl Grapher for Graph { ) } } + +#[derive(PartialEq, Eq, Clone)] +pub enum GraphType { + Hidden, + Frequency, + Usage, + Temperature, + Unknown, +} + +impl fmt::Display for GraphType { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + GraphType::Hidden => write!(f, "hidden"), + GraphType::Frequency => write!(f, "frequency"), + GraphType::Usage => write!(f, "usage"), + GraphType::Temperature => write!(f, "temperature"), + GraphType::Unknown => write!(f, "unknown"), + } + } +} + +/// Parse from graph_type parameter which type of graph will be displayed +pub fn get_graph_type(graph_type: &str) -> GraphType { + match graph_type.to_lowercase().as_str() { + "hidden" => GraphType::Hidden, + "freq" => GraphType::Frequency, + "usage" => GraphType::Usage, + "temp" => GraphType::Temperature, + _ => GraphType::Unknown, + } +} diff --git a/src/interactive.rs b/src/interactive.rs index 9d06d677..3331ce5b 100644 --- a/src/interactive.rs +++ b/src/interactive.rs @@ -1,6 +1,7 @@ use super::config::{get_config, Config}; +use super::graph::GraphType; use super::interface::{DaemonControl, DaemonController, Get, Getter, Interface, Set, Setter}; -use super::settings::{GraphType, Settings}; +use super::settings::Settings; use colored::Colorize; use std::io::{stdin, stdout, Write}; diff --git a/src/settings.rs b/src/settings.rs index 391bb51a..2310a9c8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -1,36 +1,4 @@ -use std::fmt; - -#[derive(PartialEq, Eq, Clone)] -pub enum GraphType { - Hidden, - Frequency, - Usage, - Temperature, - Unknown, -} - -impl fmt::Display for GraphType { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - GraphType::Hidden => write!(f, "hidden"), - GraphType::Frequency => write!(f, "frequency"), - GraphType::Usage => write!(f, "usage"), - GraphType::Temperature => write!(f, "temperature"), - GraphType::Unknown => write!(f, "unknown"), - } - } -} - -/// Parse from graph_type parameter which type of graph will be displayed -pub fn get_graph_type(graph_type: &str) -> GraphType { - match graph_type.to_lowercase().as_str() { - "hidden" => GraphType::Hidden, - "freq" => GraphType::Frequency, - "usage" => GraphType::Usage, - "temp" => GraphType::Temperature, - _ => GraphType::Unknown, - } -} +use super::graph::GraphType; #[derive(Clone)] pub struct Settings {