mirror of
https://github.com/Llewellynvdm/starship.git
synced 2025-04-07 01:31:50 +00:00
perf: evaluate swift version lazily (#2159)
* perf(swift): evaluate version lazily * fix(swift): update format string Co-authored-by: Moritz Vetter <mv@3yourmind.com>
This commit is contained in:
parent
45bab3a42c
commit
2391a2863c
@ -2317,8 +2317,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 Swift |
|
| `symbol` | `"🐦 "` | A format string representing the symbol of Swift |
|
||||||
| `style` | `"bold 202"` | The style for the module. |
|
| `style` | `"bold 202"` | The style for the module. |
|
||||||
| `disabled` | `false` | Disables the `swift` module. |
|
| `disabled` | `false` | Disables the `swift` module. |
|
||||||
|
@ -13,7 +13,7 @@ pub struct SwiftConfig<'a> {
|
|||||||
impl<'a> RootModuleConfig<'a> for SwiftConfig<'a> {
|
impl<'a> RootModuleConfig<'a> for SwiftConfig<'a> {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
SwiftConfig {
|
SwiftConfig {
|
||||||
format: "via [$symbol$version]($style) ",
|
format: "via [$symbol($version )]($style)",
|
||||||
symbol: "🐦 ",
|
symbol: "🐦 ",
|
||||||
style: "bold 202",
|
style: "bold 202",
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
@ -19,8 +19,6 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let swift_version = utils::exec_cmd("swift", &["--version"])?.stdout;
|
|
||||||
|
|
||||||
let mut module = context.new_module("swift");
|
let mut module = context.new_module("swift");
|
||||||
let config: SwiftConfig = SwiftConfig::try_load(module.config);
|
let config: SwiftConfig = SwiftConfig::try_load(module.config);
|
||||||
|
|
||||||
@ -35,7 +33,10 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
"version" => parse_swift_version(&swift_version).map(Ok),
|
"version" => {
|
||||||
|
let swift_version = utils::exec_cmd("swift", &["--version"])?.stdout;
|
||||||
|
parse_swift_version(&swift_version).map(Ok)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.parse(None)
|
.parse(None)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user