@@ -6,7 +6,7 @@ import (
"time"
"github.com/caarlos0/duration"
- "github.com/caarlos0/tablewriter"
+ "github.com/charmbracelet/lipgloss/table"
"github.com/charmbracelet/soft-serve/pkg/backend"
"github.com/charmbracelet/soft-serve/pkg/proto"
"github.com/dustin/go-humanize"
@@ -92,28 +92,25 @@ func TokenCommand() *cobra.Command {
}
now := time.Now()
- return tablewriter.Render(
- cmd.OutOrStdout(),
- tokens,
- []string{"ID", "Name", "Created At", "Expires In"},
- func(t proto.AccessToken) ([]string, error) {
- expiresAt := "-"
- if !t.ExpiresAt.IsZero() {
- if now.After(t.ExpiresAt) {
- expiresAt = "expired"
- } else {
- expiresAt = humanize.Time(t.ExpiresAt)
- }
+ table := table.New().Headers("ID", "Name", "Created At", "Expires In")
+ for _, token := range tokens {
+ expiresAt := "-"
+ if !token.ExpiresAt.IsZero() {
+ if now.After(token.ExpiresAt) {
+ expiresAt = "expired"
+ } else {
+ expiresAt = humanize.Time(token.ExpiresAt)
}
+ }
- return []string{
- strconv.FormatInt(t.ID, 10),
- t.Name,
- humanize.Time(t.CreatedAt),
- expiresAt,
- }, nil
- },
- )
+ table = table.Row(strconv.FormatInt(token.ID, 10),
+ token.Name,
+ humanize.Time(token.CreatedAt),
+ expiresAt,
+ )
+ }
+ cmd.Println(table)
+ return nil
},
}
@@ -5,7 +5,7 @@ import (
"strconv"
"strings"
- "github.com/caarlos0/tablewriter"
+ "github.com/charmbracelet/lipgloss/table"
"github.com/charmbracelet/soft-serve/pkg/backend"
"github.com/charmbracelet/soft-serve/pkg/webhook"
"github.com/dustin/go-humanize"
@@ -60,28 +60,24 @@ func webhookListCommand() *cobra.Command {
return err
}
- return tablewriter.Render(
- cmd.OutOrStdout(),
- webhooks,
- []string{"ID", "URL", "Events", "Active", "Created At", "Updated At"},
- func(h webhook.Hook) ([]string, error) {
- events := make([]string, len(h.Events))
- for i, e := range h.Events {
- events[i] = e.String()
- }
-
- row := []string{
- strconv.FormatInt(h.ID, 10),
- h.URL,
- strings.Join(events, ","),
- strconv.FormatBool(h.Active),
- humanize.Time(h.CreatedAt),
- humanize.Time(h.UpdatedAt),
- }
+ table := table.New().Headers("ID", "URL", "Events", "Active", "Created At", "Updated At")
+ for _, h := range webhooks {
+ events := make([]string, len(h.Events))
+ for i, e := range h.Events {
+ events[i] = e.String()
+ }
- return row, nil
- },
- )
+ table = table.Row(
+ strconv.FormatInt(h.ID, 10),
+ h.URL,
+ strings.Join(events, ","),
+ strconv.FormatBool(h.Active),
+ humanize.Time(h.CreatedAt),
+ humanize.Time(h.UpdatedAt),
+ )
+ }
+ cmd.Println(table)
+ return nil
},
}
@@ -290,24 +286,21 @@ func webhookDeliveriesListCommand() *cobra.Command {
return err
}
- return tablewriter.Render(
- cmd.OutOrStdout(),
- dels,
- []string{"Status", "ID", "Event", "Created At"},
- func(d webhook.Delivery) ([]string, error) {
- status := "❌"
- if d.ResponseStatus >= 200 && d.ResponseStatus < 300 {
- status = "✅"
- }
-
- return []string{
- status,
- d.ID.String(),
- d.Event.String(),
- humanize.Time(d.CreatedAt),
- }, nil
- },
- )
+ table := table.New().Headers("Status", "ID", "Event", "Created At")
+ for _, d := range dels {
+ status := "❌"
+ if d.ResponseStatus >= 200 && d.ResponseStatus < 300 {
+ status = "✅"
+ }
+ table = table.Row(
+ status,
+ d.ID.String(),
+ d.Event.String(),
+ humanize.Time(d.CreatedAt),
+ )
+ }
+ cmd.Println(table)
+ return nil
},
}