Skip to content

Commit

Permalink
feat: add always enabled to execution time
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Dec 12, 2020
1 parent 1777f1d commit d5b41b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/docs/segment-executiontime.md
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion segment_executiontime.go
Expand Up @@ -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)))
Expand Down
6 changes: 6 additions & 0 deletions themes/schema.json
Expand Up @@ -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",
Expand Down

0 comments on commit d5b41b3

Please sign in to comment.