diff --git a/docs/config/README.md b/docs/config/README.md index 599d0827..72b48ab4 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -1929,12 +1929,12 @@ The module will be shown if any of the following conditions are met: ### Options -| Option | Default | Description | -| ---------- | ---------------------------------- | ----------------------------------------------------- | -| `format` | `"via [$symbol$version]($style) "` | The format string for the module. | -| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl | -| `style` | `"bold 149"` | The style for the module. | -| `disabled` | `false` | Disables the `perl` module. | +| Option | Default | Description | +| ---------- | ------------------------------------ | ----------------------------------------------------- | +| `format` | `"via [$symbol($version )]($style)"` | The format string for the module. | +| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl | +| `style` | `"bold 149"` | The style for the module. | +| `disabled` | `false` | Disables the `perl` module. | ### Variables diff --git a/src/configs/perl.rs b/src/configs/perl.rs index 9f526fbf..cd86461e 100644 --- a/src/configs/perl.rs +++ b/src/configs/perl.rs @@ -15,7 +15,7 @@ impl<'a> RootModuleConfig<'a> for PerlConfig<'a> { PerlConfig { symbol: "🐪 ", style: "149 bold", - format: "via [$symbol$version]($style) ", + format: "via [$symbol($version )]($style)", disabled: false, } } diff --git a/src/modules/perl.rs b/src/modules/perl.rs index a3b33f1b..b3a6e7be 100644 --- a/src/modules/perl.rs +++ b/src/modules/perl.rs @@ -29,8 +29,6 @@ pub fn module<'a>(context: &'a Context) -> Option> { return None; } - let perl_version = utils::exec_cmd("perl", &["-e", "printf q#%vd#,$^V;"])?.stdout; - let mut module = context.new_module("perl"); let config: PerlConfig = PerlConfig::try_load(module.config); @@ -45,7 +43,11 @@ pub fn module<'a>(context: &'a Context) -> Option> { _ => None, }) .map(|variable| match variable { - "version" => Some(Ok(format!("v{}", &perl_version))), + "version" => { + let perl_version = + utils::exec_cmd("perl", &["-e", "printf q#%vd#,$^V;"])?.stdout; + Some(Ok(format!("v{}", perl_version))) + } _ => None, }) .parse(None) @@ -88,8 +90,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -103,8 +105,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -118,8 +120,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -133,8 +135,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -148,8 +150,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -163,8 +165,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -178,8 +180,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -193,8 +195,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -208,8 +210,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close() @@ -223,8 +225,8 @@ mod tests { let actual = ModuleRenderer::new("perl").path(dir.path()).collect(); let expected = Some(format!( - "via {} ", - Color::Fixed(149).bold().paint("🐪 v5.26.1") + "via {}", + Color::Fixed(149).bold().paint("🐪 v5.26.1 ") )); assert_eq!(expected, actual); dir.close()