From d5b41b37b22f70ef90cb780b3eb9df0ed83c60cf Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 12 Dec 2020 12:53:06 +0100 Subject: [PATCH] feat: add always enabled to execution time --- docs/docs/segment-executiontime.md | 2 +- segment_executiontime.go | 3 ++- themes/schema.json | 6 ++++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/docs/segment-executiontime.md b/docs/docs/segment-executiontime.md index e27570ddb054..b6b9f325eee1 100644 --- a/docs/docs/segment-executiontime.md +++ b/docs/docs/segment-executiontime.md @@ -29,10 +29,10 @@ To use this, use the PowerShell module, or confirm that you are passing an `exec ## Properties +- always_enabled: `boolean` - always show the duration - defaults to `false` - threshold: `number` - minimum duration (milliseconds) required to enable this segment - defaults to `500` - style: `enum` - one of the available format options - defaults to `austin` - ## Style Style specifies the format in which the time will be displayed. The table below shows some example times in each option. diff --git a/segment_executiontime.go b/segment_executiontime.go index 91b666a4f6fe..724cd53cc915 100644 --- a/segment_executiontime.go +++ b/segment_executiontime.go @@ -37,9 +37,10 @@ const ( ) func (t *executiontime) enabled() bool { + alwaysEnabled := t.props.getBool(AlwaysEnabled, false) executionTimeMs := t.env.executionTime() thresholdMs := t.props.getFloat64(ThresholdProperty, float64(500)) - if executionTimeMs < thresholdMs { + if !alwaysEnabled && executionTimeMs < thresholdMs { return false } style := DurationStyle(t.props.getString(Style, string(Austin))) diff --git a/themes/schema.json b/themes/schema.json index 0878b32f70d1..6f465ec186d4 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -1145,6 +1145,12 @@ "properties": { "properties": { "properties": { + "always_enabled": { + "type": "boolean", + "title": "Always Enabled", + "description": "Always show the duration", + "default": false + }, "threshold": { "type": "number", "title": "Threshold",