mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-25 06:07:43 +00:00
perf(java): Lazy eval java (#2168)
* perf(java): evaluate version lazily * fix(java): update format string * fix: use suggested format string Co-authored-by: Moritz Vetter <mv@3yourmind.com>
This commit is contained in:
parent
b065758b1c
commit
83e0432a75
@ -1335,8 +1335,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 for the module. |
|
| `format` | `"via [${symbol}(${version} )]($style)"` | The format for the module. |
|
||||||
| `symbol` | `"☕ "` | A format string representing the symbol of Java |
|
| `symbol` | `"☕ "` | A format string representing the symbol of Java |
|
||||||
| `style` | `"red dimmed"` | The style for the module. |
|
| `style` | `"red dimmed"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `java` module. |
|
| `disabled` | `false` | Disables the `java` module. |
|
||||||
|
@ -13,7 +13,7 @@ pub struct JavaConfig<'a> {
|
|||||||
impl<'a> RootModuleConfig<'a> for JavaConfig<'a> {
|
impl<'a> RootModuleConfig<'a> for JavaConfig<'a> {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
JavaConfig {
|
JavaConfig {
|
||||||
format: "via [$symbol$version]($style) ",
|
format: "via [$symbol($version )]($style)",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
style: "red dimmed",
|
style: "red dimmed",
|
||||||
symbol: "☕ ",
|
symbol: "☕ ",
|
||||||
|
@ -32,8 +32,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let java_version = get_java_version(context)?;
|
|
||||||
|
|
||||||
let mut module = context.new_module("java");
|
let mut module = context.new_module("java");
|
||||||
let config: JavaConfig = JavaConfig::try_load(module.config);
|
let config: JavaConfig = JavaConfig::try_load(module.config);
|
||||||
|
|
||||||
@ -48,7 +46,10 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
"version" => Some(Ok(&java_version)),
|
"version" => {
|
||||||
|
let java_version = get_java_version(context)?;
|
||||||
|
Some(Ok(java_version))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.parse(None)
|
.parse(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user