mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-22 19:00:13 -04:00
remove unused display options
This commit is contained in:
@@ -32,13 +32,8 @@ import (
|
||||
)
|
||||
|
||||
// ShowOutput displays the output using the proper formatter as applicable
|
||||
func ShowOutput(ctx context.Context, result *queryresult.Result, opts ...DisplayOption) int {
|
||||
func ShowOutput(ctx context.Context, result *queryresult.Result) int {
|
||||
rowErrors := 0
|
||||
config := newDisplayConfiguration()
|
||||
for _, o := range opts {
|
||||
o(config)
|
||||
}
|
||||
|
||||
var timingResult *queryresult.TimingResult
|
||||
|
||||
outputFormat := cmdconfig.Viper().GetString(pconstants.ArgOutput)
|
||||
@@ -54,7 +49,7 @@ func ShowOutput(ctx context.Context, result *queryresult.Result, opts ...Display
|
||||
}
|
||||
|
||||
// show timing
|
||||
if config.timing != pconstants.ArgOff && timingResult != nil {
|
||||
if viper.GetString(pconstants.ArgTiming) != pconstants.ArgOff && timingResult != nil {
|
||||
str := buildTimingString(timingResult)
|
||||
if viper.GetBool(constants.ConfigKeyInteractive) {
|
||||
fmt.Println(str)
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package display
|
||||
|
||||
import (
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
)
|
||||
|
||||
type displayConfiguration struct {
|
||||
timing string
|
||||
}
|
||||
|
||||
// newDisplayConfiguration creates a default configuration with timing set to
|
||||
// true if both --timing is not 'off' and --output is table
|
||||
func newDisplayConfiguration() *displayConfiguration {
|
||||
return &displayConfiguration{
|
||||
timing: cmdconfig.Viper().GetString(constants.ArgTiming),
|
||||
}
|
||||
}
|
||||
|
||||
type DisplayOption = func(config *displayConfiguration)
|
||||
|
||||
// WithTimingDisabled forcefully disables display of timing data
|
||||
func WithTimingDisabled() DisplayOption {
|
||||
return func(o *displayConfiguration) {
|
||||
o.timing = constants.ArgOff
|
||||
}
|
||||
}
|
||||
@@ -2,29 +2,6 @@ package queryresult
|
||||
|
||||
import "github.com/turbot/pipe-fittings/queryresult"
|
||||
|
||||
type TimingResultStream chan *TimingResult
|
||||
|
||||
type TimingResult struct {
|
||||
DurationMs int64 `json:"duration_ms"`
|
||||
Scans []*ScanMetadataRow `json:"scans"`
|
||||
ScanCount int64 `json:"scan_count,omitempty"`
|
||||
RowsReturned int64 `json:"rows_returned"`
|
||||
UncachedRowsFetched int64 `json:"uncached_rows_fetched"`
|
||||
CachedRowsFetched int64 `json:"cached_rows_fetched"`
|
||||
HydrateCalls int64 `json:"hydrate_calls"`
|
||||
ConnectionCount int64 `json:"connection_count"`
|
||||
}
|
||||
|
||||
func (r *TimingResult) Initialise(summary *QueryRowSummary, scans []*ScanMetadataRow) {
|
||||
r.ScanCount = summary.ScanCount
|
||||
r.ConnectionCount = summary.ConnectionCount
|
||||
r.UncachedRowsFetched = summary.UncachedRowsFetched
|
||||
r.CachedRowsFetched = summary.CachedRowsFetched
|
||||
r.HydrateCalls = summary.HydrateCalls
|
||||
// populate scans - note this may not be all scans
|
||||
r.Scans = scans
|
||||
}
|
||||
|
||||
// Result is a type alias for queryresult.Result[TimingResultStream]
|
||||
type Result = queryresult.Result[TimingResultStream]
|
||||
|
||||
|
||||
24
pkg/query/queryresult/timing_result.go
Normal file
24
pkg/query/queryresult/timing_result.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package queryresult
|
||||
|
||||
type TimingResultStream chan *TimingResult
|
||||
|
||||
type TimingResult struct {
|
||||
DurationMs int64 `json:"duration_ms"`
|
||||
Scans []*ScanMetadataRow `json:"scans"`
|
||||
ScanCount int64 `json:"scan_count,omitempty"`
|
||||
RowsReturned int64 `json:"rows_returned"`
|
||||
UncachedRowsFetched int64 `json:"uncached_rows_fetched"`
|
||||
CachedRowsFetched int64 `json:"cached_rows_fetched"`
|
||||
HydrateCalls int64 `json:"hydrate_calls"`
|
||||
ConnectionCount int64 `json:"connection_count"`
|
||||
}
|
||||
|
||||
func (r *TimingResult) Initialise(summary *QueryRowSummary, scans []*ScanMetadataRow) {
|
||||
r.ScanCount = summary.ScanCount
|
||||
r.ConnectionCount = summary.ConnectionCount
|
||||
r.UncachedRowsFetched = summary.UncachedRowsFetched
|
||||
r.CachedRowsFetched = summary.CachedRowsFetched
|
||||
r.HydrateCalls = summary.HydrateCalls
|
||||
// populate scans - note this may not be all scans
|
||||
r.Scans = scans
|
||||
}
|
||||
Reference in New Issue
Block a user