diff --git a/src/context.rs b/src/context.rs index d440abf0..4a10d242 100644 --- a/src/context.rs +++ b/src/context.rs @@ -77,14 +77,14 @@ impl<'a> Context<'a> { Module::new(name, config) } - /// Check the `disabled` configuration of the module - pub fn is_module_enabled(&self, name: &str) -> bool { + /// Check if `disabled` option of the module is true in configuration file. + pub fn is_module_disabled_in_config(&self, name: &str) -> bool { let config = self.config.get_module_config(name); // If the segment has "disabled" set to "true", don't show it let disabled = config.and_then(|table| table.as_table()?.get("disabled")?.as_bool()); - disabled != Some(true) + disabled == Some(true) } // returns a new ScanDir struct with reference to current dir_files of context diff --git a/src/modules/kubernetes.rs b/src/modules/kubernetes.rs index 40de44a9..c646455e 100644 --- a/src/modules/kubernetes.rs +++ b/src/modules/kubernetes.rs @@ -53,6 +53,9 @@ pub fn module<'a>(context: &'a Context) -> Option> { let mut module = context.new_module("kubernetes"); let config: KubernetesConfig = KubernetesConfig::try_load(module.config); + if config.disabled { + return None; + }; module.set_style(config.style); module.get_prefix().set_value(KUBERNETES_PREFIX); diff --git a/src/print.rs b/src/print.rs index 591ff32a..891890ee 100644 --- a/src/print.rs +++ b/src/print.rs @@ -36,7 +36,7 @@ pub fn prompt(args: ArgMatches) { let modules = &prompt_order .par_iter() - .filter(|module| context.is_module_enabled(module)) + .filter(|module| !context.is_module_disabled_in_config(module)) .map(|module| modules::handle(module, &context)) // Compute modules .flatten() .collect::>(); // Remove segments set to `None`