diff options
author | Clement Tsang <34804052+ClementTsang@users.noreply.github.com> | 2020-11-20 00:13:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-20 00:13:46 -0500 |
commit | 2ff8b418b2da57dbe7f2662b37023fc0c70bc6fd (patch) | |
tree | c6168c242b254a7931986596271087869d203a93 /src/options.rs | |
parent | 5fedf8a5db3fcc21656e653674bc5aed8d66fde3 (diff) |
feature: add tree flag (#312)
Adds a --tree flag that defaults to tree mode for the process widget.
Diffstat (limited to 'src/options.rs')
-rw-r--r-- | src/options.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/options.rs b/src/options.rs index 15fe6f1b..21da8427 100644 --- a/src/options.rs +++ b/src/options.rs @@ -144,6 +144,9 @@ pub struct ConfigFlags { #[builder(default, setter(strip_option))] pub mem_as_value: Option<bool>, + + #[builder(default, setter(strip_option))] + pub tree: Option<bool>, } #[derive(Clone, Default, Debug, Deserialize, Serialize)] @@ -235,6 +238,7 @@ pub fn build_app( let mut used_widget_set = HashSet::new(); let show_memory_as_values = get_mem_as_value(matches, config); + let is_default_tree = get_is_default_tree(matches, config); for row in &widget_layout.rows { for col in &row.children { @@ -302,6 +306,7 @@ pub fn build_app( is_use_regex, is_grouped, show_memory_as_values, + is_default_tree, ), ); } @@ -937,3 +942,14 @@ fn get_mem_as_value(matches: &clap::ArgMatches<'static>, config: &Config) -> boo } false } + +fn get_is_default_tree(matches: &clap::ArgMatches<'static>, config: &Config) -> bool { + if matches.is_present("tree") { + return true; + } else if let Some(flags) = &config.flags { + if let Some(tree) = flags.tree { + return tree; + } + } + false +} |