diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-11-19 00:28:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-19 00:28:04 -0500 |
commit | 92636f3bf91a1872b6b4249e78fce79e9fb51b6d (patch) | |
tree | 7660dc17555891b1016cc57df9c9bc644feadfbc /src/options.rs | |
parent | c0a8c347e12ae7924ed78ee9c35f2acd7152193e (diff) |
feature: Add mem_as_value flag (#309)
Adds a new flag, --mem_as_value (and its corresponding config option, mem_as_value = true), which defaults to showing process memory values by their amount rather than percentage.
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs index 9c1e6215..15fe6f1b 100644 --- a/src/options.rs +++ b/src/options.rs @@ -141,6 +141,9 @@ pub struct ConfigFlags { #[builder(default, setter(strip_option))] pub search_regex_enabled_widgets: Option<Vec<WidgetIdEnabled>>, + + #[builder(default, setter(strip_option))] + pub mem_as_value: Option<bool>, } #[derive(Clone, Default, Debug, Deserialize, Serialize)] @@ -231,6 +234,8 @@ pub fn build_app( let is_custom_layout = config.row.is_some(); let mut used_widget_set = HashSet::new(); + let show_memory_as_values = get_mem_as_value(matches, config); + for row in &widget_layout.rows { for col in &row.children { for col_row in &col.children { @@ -296,6 +301,7 @@ pub fn build_app( is_match_whole_word, is_use_regex, is_grouped, + show_memory_as_values, ), ); } @@ -920,3 +926,14 @@ pub fn get_color_scheme( // And lastly, the final case is just "default". Ok(ColourScheme::Default) } + +fn get_mem_as_value(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { + if matches.is_present("mem_as_value") { + return true; + } else if let Some(flags) = &config.flags { + if let Some(mem_as_value) = flags.mem_as_value { + return mem_as_value; + } + } + false +} |