mirror of
https://github.com/starship/starship.git
synced 2025-06-24 20:01:59 +02:00
perf(perl): Lazy eval perl (#2189)
* perf(perl): evaluate version lazily * fix(perl): update format string; update tests * refact(perl): run rustfmt Co-authored-by: Moritz Vetter <mv@3yourmind.com>
This commit is contained in:
parent
d10a83ce6b
commit
16b8cbfdb8
@ -1930,8 +1930,8 @@ The module will be shown if any of the following conditions are met:
|
|||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
| ---------- | ---------------------------------- | ----------------------------------------------------- |
|
| ---------- | ------------------------------------ | ----------------------------------------------------- |
|
||||||
| `format` | `"via [$symbol$version]($style) "` | The format string for the module. |
|
| `format` | `"via [$symbol($version )]($style)"` | The format string for the module. |
|
||||||
| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl |
|
| `symbol` | `"🐪 "` | The symbol used before displaying the version of Perl |
|
||||||
| `style` | `"bold 149"` | The style for the module. |
|
| `style` | `"bold 149"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `perl` module. |
|
| `disabled` | `false` | Disables the `perl` module. |
|
||||||
|
@ -15,7 +15,7 @@ impl<'a> RootModuleConfig<'a> for PerlConfig<'a> {
|
|||||||
PerlConfig {
|
PerlConfig {
|
||||||
symbol: "🐪 ",
|
symbol: "🐪 ",
|
||||||
style: "149 bold",
|
style: "149 bold",
|
||||||
format: "via [$symbol$version]($style) ",
|
format: "via [$symbol($version )]($style)",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let perl_version = utils::exec_cmd("perl", &["-e", "printf q#%vd#,$^V;"])?.stdout;
|
|
||||||
|
|
||||||
let mut module = context.new_module("perl");
|
let mut module = context.new_module("perl");
|
||||||
let config: PerlConfig = PerlConfig::try_load(module.config);
|
let config: PerlConfig = PerlConfig::try_load(module.config);
|
||||||
|
|
||||||
@ -45,7 +43,11 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.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,
|
_ => None,
|
||||||
})
|
})
|
||||||
.parse(None)
|
.parse(None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user