mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-25 01:34:19 +02:00
left align ints by default again, add -I to right align on request
This commit is contained in:
@@ -71,6 +71,13 @@ func Main() int {
|
|||||||
Destination: &tree,
|
Destination: &tree,
|
||||||
Hidden: true,
|
Hidden: true,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "align-ints",
|
||||||
|
Aliases: []string{"I"},
|
||||||
|
Value: false,
|
||||||
|
Usage: "right align integers in tabular output",
|
||||||
|
Destination: &conf.AlignInts,
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "config",
|
Name: "config",
|
||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ type Config struct {
|
|||||||
DefaultCluster *Cluster
|
DefaultCluster *Cluster
|
||||||
HaveJQ bool // determined at runtime by ourselfes
|
HaveJQ bool // determined at runtime by ourselfes
|
||||||
ProfileFile string // for internal use (golang profiling)
|
ProfileFile string // for internal use (golang profiling)
|
||||||
|
AlignInts bool // -I
|
||||||
|
|
||||||
Index string // index: -i
|
Index string // index: -i
|
||||||
Failed, Partials bool // index: flags
|
Failed, Partials bool // index: flags
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type Table struct {
|
|||||||
Entries [][]string
|
Entries [][]string
|
||||||
|
|
||||||
lenHeaders []int
|
lenHeaders []int
|
||||||
|
alignInts bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
||||||
@@ -45,6 +46,7 @@ func NewTable(conf *cfg.Config, columns, rows int) *Table {
|
|||||||
table.Headers = make([]string, columns)
|
table.Headers = make([]string, columns)
|
||||||
table.Entries = make([][]string, rows)
|
table.Entries = make([][]string, rows)
|
||||||
table.lenHeaders = make([]int, columns)
|
table.lenHeaders = make([]int, columns)
|
||||||
|
table.alignInts = conf.AlignInts
|
||||||
|
|
||||||
return &table
|
return &table
|
||||||
}
|
}
|
||||||
@@ -137,7 +139,7 @@ func (data *Table) PrintTSV() error {
|
|||||||
for idx, entry := range entries {
|
for idx, entry := range entries {
|
||||||
length := visibleLen(entry)
|
length := visibleLen(entry)
|
||||||
|
|
||||||
if isInt(entry) {
|
if isInt(entry) && data.alignInts {
|
||||||
// align right
|
// align right
|
||||||
fmt.Print(strings.Repeat(" ", data.lenHeaders[idx]-length), entry)
|
fmt.Print(strings.Repeat(" ", data.lenHeaders[idx]-length), entry)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user