mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 07:46:28 +00:00
fix: Add disable configuration option to kubernetes module (#491)
This commit is contained in:
parent
e5d37e0a97
commit
bc9e44f45c
@ -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
|
||||
|
@ -53,6 +53,9 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
|
||||
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);
|
||||
|
@ -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::<Vec<Module>>(); // Remove segments set to `None`
|
||||
|
Loading…
Reference in New Issue
Block a user