mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 11:04:18 +02:00
add --debug-goroutines
This commit is contained in:
@@ -35,15 +35,20 @@ type Table struct {
|
||||
RawHeaders []string
|
||||
Entries [][]any
|
||||
|
||||
rows [][]string // representation used for printing
|
||||
processed bool
|
||||
lenHeaders []int
|
||||
alignInts bool
|
||||
maxwidth int
|
||||
rows [][]string // representation used for printing
|
||||
processed bool
|
||||
lenHeaders []int
|
||||
alignInts bool
|
||||
maxwidth int
|
||||
debugGoRoutines bool
|
||||
}
|
||||
|
||||
func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
||||
table := new(Table{Mode: conf.Output, maxwidth: cfg.GetTermWidth()})
|
||||
table := new(Table{
|
||||
Mode: conf.Output,
|
||||
maxwidth: cfg.GetTermWidth(),
|
||||
debugGoRoutines: conf.DebugGoRoutines,
|
||||
})
|
||||
|
||||
table.Headers = make([]string, columns)
|
||||
table.RawHeaders = make([]string, columns)
|
||||
@@ -55,7 +60,11 @@ func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
||||
}
|
||||
|
||||
func NewTableEmpty(conf *cfg.Config) *Table {
|
||||
table := new(Table{Mode: conf.Output, maxwidth: cfg.GetTermWidth()})
|
||||
table := new(Table{
|
||||
Mode: conf.Output,
|
||||
maxwidth: cfg.GetTermWidth(),
|
||||
debugGoRoutines: conf.DebugGoRoutines,
|
||||
})
|
||||
table.alignInts = conf.AlignInts
|
||||
|
||||
return table
|
||||
@@ -75,16 +84,24 @@ func (table *Table) WithHeaders(headers ...string) *Table {
|
||||
}
|
||||
|
||||
func (table *Table) Print() error {
|
||||
var err error
|
||||
|
||||
switch table.Mode {
|
||||
case "json":
|
||||
return table.PrintJSON()
|
||||
err = table.PrintJSON()
|
||||
case "yaml":
|
||||
return table.PrintYAML()
|
||||
err = table.PrintYAML()
|
||||
case "csv":
|
||||
return table.PrintCSV()
|
||||
err = table.PrintCSV()
|
||||
default:
|
||||
return table.PrintTSV()
|
||||
err = table.PrintTSV()
|
||||
}
|
||||
|
||||
if table.debugGoRoutines {
|
||||
printGoRoutineMetrics()
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
Reference in New Issue
Block a user