mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Move util.NewTabWriter to common.NewTabWriter
This commit is contained in:
parent
1830fea7b7
commit
7589f97105
@ -53,7 +53,7 @@ var endpointListCmd = &cobra.Command{
|
||||
}
|
||||
} else {
|
||||
// Print all endpoint fields as a table
|
||||
writer, err := util.NewTabWriter([]string{
|
||||
writer, err := common.NewTabWriter([]string{
|
||||
"ENDPOINT ID",
|
||||
"NAME",
|
||||
"TYPE",
|
||||
|
@ -43,7 +43,7 @@ var stackListCmd = &cobra.Command{
|
||||
}
|
||||
} else {
|
||||
// Print all stack fields as a table
|
||||
writer, err := util.NewTabWriter([]string{
|
||||
writer, err := common.NewTabWriter([]string{
|
||||
"STACK ID",
|
||||
"NAME",
|
||||
"TYPE",
|
||||
|
@ -5,8 +5,6 @@ import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/greenled/portainer-stack-utils/util"
|
||||
|
||||
"github.com/greenled/portainer-stack-utils/common"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
@ -32,7 +30,7 @@ var statusCmd = &cobra.Command{
|
||||
fmt.Println()
|
||||
} else {
|
||||
// Print status fields as a table
|
||||
writer, newTabWriterErr := util.NewTabWriter([]string{
|
||||
writer, newTabWriterErr := common.NewTabWriter([]string{
|
||||
"VERSION",
|
||||
"AUTHENTICATION",
|
||||
"ENDPOINT MANAGEMENT",
|
||||
|
17
common/printing.go
Normal file
17
common/printing.go
Normal file
@ -0,0 +1,17 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
)
|
||||
|
||||
func NewTabWriter(headers []string) (*tabwriter.Writer, error) {
|
||||
writer := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0)
|
||||
_, err := fmt.Fprintln(writer, strings.Join(headers, "\t"))
|
||||
if err != nil {
|
||||
return &tabwriter.Writer{}, err
|
||||
}
|
||||
return writer, nil
|
||||
}
|
@ -1,11 +1,7 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@ -21,12 +17,3 @@ func PrintDebug(a ...interface{}) {
|
||||
log.Println(a)
|
||||
}
|
||||
}
|
||||
|
||||
func NewTabWriter(headers []string) (*tabwriter.Writer, error) {
|
||||
writer := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0)
|
||||
_, err := fmt.Fprintln(writer, strings.Join(headers, "\t"))
|
||||
if err != nil {
|
||||
return &tabwriter.Writer{}, err
|
||||
}
|
||||
return writer, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user