mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-29 08:00:11 -04:00
34 lines
933 B
Go
34 lines
933 B
Go
package display
|
|
|
|
import (
|
|
"github.com/turbot/steampipe/pkg/cmdconfig"
|
|
"github.com/turbot/steampipe/pkg/constants"
|
|
)
|
|
|
|
type displayConfiguration struct {
|
|
timing bool
|
|
}
|
|
|
|
// NewDisplayConfiguration creates a default configuration with timing set to
|
|
// true if both --timing is true and --output is table
|
|
func NewDisplayConfiguration() *displayConfiguration {
|
|
timingFlag := cmdconfig.Viper().GetBool(constants.ArgTiming)
|
|
isInteractive := cmdconfig.Viper().GetBool(constants.ConfigKeyInteractive)
|
|
outputTable := cmdconfig.Viper().GetString(constants.ArgOutput) == constants.OutputFormatTable
|
|
|
|
timing := timingFlag && (outputTable || isInteractive)
|
|
|
|
return &displayConfiguration{
|
|
timing: timing,
|
|
}
|
|
}
|
|
|
|
type DisplayOption = func(config *displayConfiguration)
|
|
|
|
// WithTimingDisabled forcefully disables display of timing data
|
|
func WithTimingDisabled() DisplayOption {
|
|
return func(o *displayConfiguration) {
|
|
o.timing = false
|
|
}
|
|
}
|