forked from coop-cloud/abra
refactor: Moved table function to fornatter
Makes more sense for it to be in there
This commit is contained in:
parent
2134f57dd0
commit
d1f7e8011d
@ -1,9 +1,6 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/olekukonko/tablewriter"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@ -187,23 +184,3 @@ var ContextFlag = &cli.StringFlag{
|
||||
Aliases: []string{"c"},
|
||||
Destination: &Context,
|
||||
}
|
||||
|
||||
func createTable(columns []string) *tablewriter.Table {
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetHeader(columns)
|
||||
|
||||
// Settings to create very bare tab padded table
|
||||
table.SetAutoWrapText(false)
|
||||
table.SetAutoFormatHeaders(true)
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetCenterSeparator("")
|
||||
table.SetColumnSeparator("")
|
||||
table.SetRowSeparator("")
|
||||
table.SetHeaderLine(false)
|
||||
table.SetBorder(false)
|
||||
table.SetTablePadding("\t") // pad with tabs
|
||||
table.SetNoWhiteSpace(true)
|
||||
table.SetColWidth(1)
|
||||
return table
|
||||
}
|
||||
|
@ -2,11 +2,13 @@ package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
"github.com/docker/go-units"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
)
|
||||
|
||||
func shortenID(str string) string {
|
||||
@ -28,3 +30,23 @@ func humanDuration(timestamp int64) string {
|
||||
now := time.Now().UTC()
|
||||
return units.HumanDuration(now.Sub(date)) + " ago"
|
||||
}
|
||||
|
||||
func createTable(columns []string) *tablewriter.Table {
|
||||
table := tablewriter.NewWriter(os.Stdout)
|
||||
table.SetHeader(columns)
|
||||
|
||||
// Settings to create very bare tab padded table
|
||||
table.SetAutoWrapText(false)
|
||||
table.SetAutoFormatHeaders(true)
|
||||
table.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetAlignment(tablewriter.ALIGN_LEFT)
|
||||
table.SetCenterSeparator("")
|
||||
table.SetColumnSeparator("")
|
||||
table.SetRowSeparator("")
|
||||
table.SetHeaderLine(false)
|
||||
table.SetBorder(false)
|
||||
table.SetTablePadding("\t") // pad with tabs
|
||||
table.SetNoWhiteSpace(true)
|
||||
table.SetColWidth(1)
|
||||
return table
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user