summaryrefslogtreecommitdiffstats
path: root/src/options.rs
diff options
context:
space:
mode:
authorClementTsang <cjhtsang@uwaterloo.ca>2020-03-09 00:52:29 -0400
committerClementTsang <cjhtsang@uwaterloo.ca>2020-03-09 00:52:29 -0400
commite5588f16063ccb430104ff931719bb9aca27a359 (patch)
treee4423872ed72edd1cb365407bb1e35ab86b7c953 /src/options.rs
parent78a05bc68377497dfd52eaee37c7a5e3bedd71b1 (diff)
Add hiding time and autohiding time.
Diffstat (limited to 'src/options.rs')
-rw-r--r--src/options.rs34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/options.rs b/src/options.rs
index 449cb66e..a5cd832e 100644
--- a/src/options.rs
+++ b/src/options.rs
@@ -29,6 +29,8 @@ pub struct ConfigFlags {
pub basic: Option<bool>,
pub default_time_value: Option<u64>,
pub time_delta: Option<u64>,
+ pub autohide_time: Option<bool>,
+ pub hide_time: Option<bool>,
//disabled_cpu_cores: Option<Vec<u64>>, // TODO: [FEATURE] Enable disabling cores in config/flags
}
@@ -199,9 +201,9 @@ pub fn get_default_time_value_option(
return Err(BottomError::InvalidArg(
"Please set your default value to be at least 30 seconds.".to_string(),
));
- } else if default_time as u128 > std::u64::MAX as u128 {
+ } else if default_time as u128 > STALE_MAX_MILLISECONDS as u128 {
return Err(BottomError::InvalidArg(
- "Please set your default value to be at most unsigned INT_MAX.".to_string(),
+ "Please set your default value to be at most 10 minutes.".to_string(),
));
}
@@ -227,9 +229,9 @@ pub fn get_time_interval_option(
return Err(BottomError::InvalidArg(
"Please set your time delta to be at least 1 second.".to_string(),
));
- } else if time_interval > std::u64::MAX as u128 {
+ } else if time_interval > STALE_MAX_MILLISECONDS as u128 {
return Err(BottomError::InvalidArg(
- "Please set your time delta to be at most unsigned INT_MAX.".to_string(),
+ "Please set your time delta to be at most 10 minutes.".to_string(),
));
}
@@ -288,6 +290,30 @@ pub fn enable_app_use_regex(matches: &clap::ArgMatches<'static>, config: &Config
}
}
+pub fn enable_hide_time(matches: &clap::ArgMatches<'static>, config: &Config, app: &mut App) {
+ if matches.is_present("HIDE_TIME") {
+ app.app_config_fields.hide_time = true;
+ } else if let Some(flags) = &config.flags {
+ if let Some(hide_time) = flags.hide_time {
+ if hide_time {
+ app.app_config_fields.hide_time = true;
+ }
+ }
+ }
+}
+
+pub fn enable_autohide_time(matches: &clap::ArgMatches<'static>, config: &Config, app: &mut App) {
+ if matches.is_present("AUTOHIDE_TIME") {
+ app.app_config_fields.autohide_time = true;
+ } else if let Some(flags) = &config.flags {
+ if let Some(autohide_time) = flags.autohide_time {
+ if autohide_time {
+ app.app_config_fields.autohide_time = true;
+ }
+ }
+ }
+}
+
pub fn get_default_widget(matches: &clap::ArgMatches<'static>, config: &Config) -> WidgetPosition {
if matches.is_present("CPU_WIDGET") {
return WidgetPosition::Cpu;