forked from toolshed/abra
refactor: tablewriter -> lipgloss
Also the jsontable impl. is dropped also. Output is unchanged.
This commit is contained in:
@ -2,6 +2,7 @@ package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"coopcloud.tech/abra/cli/internal"
|
||||
"coopcloud.tech/abra/pkg/autocomplete"
|
||||
@ -37,26 +38,35 @@ var appVolumeListCommand = cli.Command{
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
volumeList, err := client.GetVolumes(cl, context.Background(), app.Server, filters)
|
||||
volumes, err := client.GetVolumes(cl, context.Background(), app.Server, filters)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
table := formatter.CreateTable([]string{"name", "created", "mounted"})
|
||||
var volTable [][]string
|
||||
for _, volume := range volumeList {
|
||||
volRow := []string{volume.Name, volume.CreatedAt, volume.Mountpoint}
|
||||
volTable = append(volTable, volRow)
|
||||
headers := []string{"name", "created", "mounted"}
|
||||
|
||||
table, err := formatter.CreateTable2()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
table.AppendBulk(volTable)
|
||||
table.Headers(headers...)
|
||||
|
||||
if table.NumLines() > 0 {
|
||||
table.Render()
|
||||
} else {
|
||||
log.Warnf("no volumes created for %s", app.Name)
|
||||
var rows [][]string
|
||||
for _, volume := range volumes {
|
||||
row := []string{volume.Name, volume.CreatedAt, volume.Mountpoint}
|
||||
rows = append(rows, row)
|
||||
}
|
||||
|
||||
table.Rows(rows...)
|
||||
|
||||
if len(rows) > 0 {
|
||||
fmt.Println(table)
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Warnf("no volumes created for %s", app.Name)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user