Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions cmd/audit/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"unicode"

"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/superfly/flyctl/internal/command/root"
Expand All @@ -22,21 +23,22 @@ func newLintCmd() *cobra.Command {
root := root.New()
run := NewCheckRun(root)

table := tablewriter.NewWriter(os.Stdout)
table.SetBorder(false)
table.SetAutoWrapText(false)
table.SetHeader([]string{"Path", "Check", "Failure Reason"})
table := tablewriter.NewTable(os.Stdout,
tablewriter.WithHeader([]string{"Path", "Check", "Failure Reason"}),
tablewriter.WithRendition(tw.Rendition{
Borders: tw.Border{Left: tw.Off, Right: tw.Off, Top: tw.Off, Bottom: tw.Off},
}),
)
table.Configure(func(cfg *tablewriter.Config) {
cfg.Row.Formatting.AutoWrap = tw.WrapNone
})

errors := run.Run()
for _, err := range errors {
table.Append([]string{
err.command,
err.check,
err.Error(),
})
table.Append(err.command, err.check, err.Error()) //nolint:errcheck
}

table.Render()
table.Render() //nolint:errcheck

fmt.Println()
fmt.Printf("%d checks failed\n", len(errors))
Expand Down
32 changes: 24 additions & 8 deletions cmd/audit/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"

"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
)

func newOutput(w io.Writer, format string) output {
Expand All @@ -25,23 +26,38 @@ type output interface {
}

func NewTableOutput(w io.Writer) *tableOutput {
t := tablewriter.NewWriter(w)
t.SetBorder(false)
t.SetAutoWrapText(false)
t := tablewriter.NewTable(w,
tablewriter.WithRendition(tw.Rendition{
Borders: tw.Border{Left: tw.Off, Right: tw.Off, Top: tw.Off, Bottom: tw.Off},
}),
)
t.Configure(func(cfg *tablewriter.Config) {
cfg.Row.Formatting.AutoWrap = tw.WrapNone
})

return &tableOutput{
Table: t,
table: t,
}
}

type tableOutput struct {
*tablewriter.Table
table *tablewriter.Table
}

func (t *tableOutput) Flush() error {
t.Render()
func (t *tableOutput) SetHeader(header []string) {
t.table.Options(tablewriter.WithHeader(header))
}

func (t *tableOutput) Append(row []string) {
args := make([]interface{}, len(row))
for i, v := range row {
args[i] = v
}
t.table.Append(args...) //nolint:errcheck
}

return nil
func (t *tableOutput) Flush() error {
return t.table.Render()
}

func NewCSVOutput(w io.Writer) *csvOutput {
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ require (
github.com/nats-io/nats.go v1.43.0
github.com/novln/docker-parser v1.0.0
github.com/oklog/ulid/v2 v2.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/olekukonko/tablewriter v1.1.4
github.com/pelletier/go-toml/v2 v2.2.4
github.com/pkg/errors v0.9.1
github.com/pkg/sftp v1.13.9
Expand Down Expand Up @@ -106,11 +106,16 @@ require (
github.com/aws/aws-sdk-go-v2/service/signin v1.0.9 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.2 // indirect
github.com/clipperhouse/displaywidth v0.10.0 // indirect
github.com/clipperhouse/uax29/v2 v2.6.0 // indirect
github.com/containerd/containerd v1.7.27 // indirect
github.com/creack/pty v1.1.24 // indirect
github.com/golang-jwt/jwt/v5 v5.3.0 // indirect
github.com/google/cel-go v0.26.1 // indirect
github.com/invopop/jsonschema v0.13.0 // indirect
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
github.com/olekukonko/errors v1.2.0 // indirect
github.com/olekukonko/ll v0.1.6 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.57.1 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
Expand Down Expand Up @@ -195,7 +200,7 @@ require (
github.com/docker/go-metrics v0.0.1 // indirect
github.com/elazarl/goproxy v1.7.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/gdamore/encoding v1.0.1 // indirect
github.com/gdamore/tcell/v2 v2.8.0 // indirect
Expand Down Expand Up @@ -231,7 +236,7 @@ require (
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mark3labs/mcp-go v0.39.1
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/ioprogress v0.0.0-20180201004757-6a23b12fa88e // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
Expand Down
22 changes: 16 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04=
github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8=
github.com/cli/safeexec v1.0.1 h1:e/C79PbXF4yYTN/wauC4tviMxEV13BwljGj0N9j+N00=
github.com/cli/safeexec v1.0.1/go.mod h1:Z/D4tTN8Vs5gXYHDCbaM1S/anmEDnJb1iW0+EJ5zx3Q=
github.com/clipperhouse/displaywidth v0.10.0 h1:GhBG8WuerxjFQQYeuZAeVTuyxuX+UraiZGD4HJQ3Y8g=
github.com/clipperhouse/displaywidth v0.10.0/go.mod h1:XqJajYsaiEwkxOj4bowCTMcT1SgvHo9flfF3jQasdbs=
github.com/clipperhouse/uax29/v2 v2.6.0 h1:z0cDbUV+aPASdFb2/ndFnS9ts/WNXgTNNGFoKXuhpos=
github.com/clipperhouse/uax29/v2 v2.6.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g=
github.com/cloudflare/circl v1.6.3 h1:9GPOhQGF9MCYUeXyMYlqTR6a5gTrgR/fBLXvUgtVcg8=
github.com/cloudflare/circl v1.6.3/go.mod h1:2eXP6Qfat4O/Yhh8BznvKnJ+uzEoTQ6jVKJRn81BiS4=
github.com/codahale/rfc6979 v0.0.0-20141003034818-6a90f24967eb h1:EDmT6Q9Zs+SbUoc7Ik9EfrFqcylYqgPZ9ANSbTAntnE=
Expand Down Expand Up @@ -277,8 +281,8 @@ github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVo
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
Expand Down Expand Up @@ -455,10 +459,10 @@ github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/mattn/go-zglob v0.0.6 h1:mP8RnmCgho4oaUYDIDn6GNxYk+qJGUs8fJLn+twYj2A=
github.com/mattn/go-zglob v0.0.6/go.mod h1:MxxjyoXXnMxfIpxTK2GAkw1w8glPsQILx3N5wrKakiY=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
Expand Down Expand Up @@ -514,8 +518,14 @@ github.com/novln/docker-parser v1.0.0 h1:PjEBd9QnKixcWczNGyEdfUrP6GR0YUilAqG7Wks
github.com/novln/docker-parser v1.0.0/go.mod h1:oCeM32fsoUwkwByB5wVjsrsVQySzPWkl3JdlTn1txpE=
github.com/oklog/ulid/v2 v2.1.0 h1:+9lhoxAP56we25tyYETBBY1YLA2SaoLvUFgrP2miPJU=
github.com/oklog/ulid/v2 v2.1.0/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
github.com/olekukonko/errors v1.2.0 h1:10Zcn4GeV59t/EGqJc8fUjtFT/FuUh5bTMzZ1XwmCRo=
github.com/olekukonko/errors v1.2.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
github.com/olekukonko/ll v0.1.6 h1:lGVTHO+Qc4Qm+fce/2h2m5y9LvqaW+DCN7xW9hsU3uA=
github.com/olekukonko/ll v0.1.6/go.mod h1:NVUmjBb/aCtUpjKk75BhWrOlARz3dqsM+OtszpY4o88=
github.com/olekukonko/tablewriter v1.1.4 h1:ORUMI3dXbMnRlRggJX3+q7OzQFDdvgbN9nVWj1drm6I=
github.com/olekukonko/tablewriter v1.1.4/go.mod h1:+kedxuyTtgoZLwif3P1Em4hARJs+mVnzKxmsCL/C5RY=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
Expand Down
29 changes: 13 additions & 16 deletions helpers/tablehelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,22 @@ import (
"io"

tablewriter "github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
)

func MakeSimpleTable(out io.Writer, headings []string) (table *tablewriter.Table) {
newtable := tablewriter.NewWriter(out)
// Future code to turn headers bold
// headercolors := []tablewriter.Colors{}
// for range headings {
// headercolors = append(headercolors, tablewriter.Colors{tablewriter.Bold})
// }
newtable.SetHeader(headings)
newtable.SetHeaderLine(true)
newtable.SetBorder(false)
newtable.SetAutoFormatHeaders(true)
newtable.SetHeaderAlignment(tablewriter.ALIGN_LEFT)
newtable.SetAlignment(tablewriter.ALIGN_LEFT)
newtable.SetTablePadding(" ")
newtable.SetCenterSeparator("*")
newtable.SetRowSeparator("-")
newtable.SetAutoWrapText(false)
newtable := tablewriter.NewTable(out,
tablewriter.WithHeader(headings),
tablewriter.WithHeaderAlignment(tw.AlignLeft),
tablewriter.WithRowAlignment(tw.AlignLeft),
tablewriter.WithRendition(tw.Rendition{
Borders: tw.Border{Left: tw.Off, Right: tw.Off, Top: tw.Off, Bottom: tw.Off},
}),
)
newtable.Configure(func(cfg *tablewriter.Config) {
cfg.Header.Formatting.AutoFormat = tw.On
cfg.Row.Formatting.AutoWrap = tw.WrapNone
})

return newtable
}
5 changes: 2 additions & 3 deletions internal/command/checks/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func runAppCheckList(ctx context.Context) error {

fmt.Fprintf(out, "Health Checks for %s\n", appName)
table := helpers.MakeSimpleTable(out, []string{"Name", "Status", "Machine", "Last Updated", "Output"})
table.SetRowLine(true)
for _, machine := range machines {
sort.Slice(machine.Checks, func(i, j int) bool {
return machine.Checks[i].Name < machine.Checks[j].Name
Expand All @@ -55,10 +54,10 @@ func runAppCheckList(ctx context.Context) error {
if nameFilter != "" && nameFilter != check.Name {
continue
}
table.Append([]string{check.Name, string(check.Status), machine.ID, format.RelativeTime(*check.UpdatedAt), check.Output})
table.Append(check.Name, string(check.Status), machine.ID, format.RelativeTime(*check.UpdatedAt), check.Output) //nolint:errcheck
}
}
table.Render()
table.Render() //nolint:errcheck

return nil
}
4 changes: 2 additions & 2 deletions internal/command/deploy/machines_deploymachinesapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,10 @@ func (md *machineDeployment) warnAboutIncorrectListenAddress(ctx context.Context
}
}
if len(addresses) > 0 {
table.Append([]string{proc.Command, strings.Join(addresses, ", ")})
table.Append(proc.Command, strings.Join(addresses, ", ")) //nolint:errcheck
}
}
table.Render()
table.Render() //nolint:errcheck
fmt.Fprintf(md.io.ErrOut, "\n")
}

Expand Down
5 changes: 2 additions & 3 deletions internal/command/incidents/hosts/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ func runList(ctx context.Context) (err error) {
if appHostIssuesCount > 0 {
fmt.Fprintf(out, "Host Issues count: %d\n\n", appHostIssuesCount)
table := helpers.MakeSimpleTable(out, []string{"Id", "Message", "Started At", "Last Updated"})
table.SetRowLine(true)
for _, appHostIssue := range appHostIssues {
table.Append([]string{appHostIssue.InternalId, appHostIssue.Message, appHostIssue.CreatedAt.String(), appHostIssue.UpdatedAt.String()})
table.Append(appHostIssue.InternalId, appHostIssue.Message, appHostIssue.CreatedAt.String(), appHostIssue.UpdatedAt.String()) //nolint:errcheck
}
table.Render()
table.Render() //nolint:errcheck
} else {
fmt.Fprintf(out, "There are no active host issues\n")
}
Expand Down
5 changes: 2 additions & 3 deletions internal/command/incidents/incidents.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ func runIncidentsList(ctx context.Context) error {
if incidentCount > 0 {
fmt.Fprintf(out, "Incidents count: %d\n\n", incidentCount)
table := helpers.MakeSimpleTable(out, []string{"Id", "Name", "Status", "Components", "Started At", "Last Updated"})
table.SetRowLine(true)
for _, incident := range statuspageIncidents.Incidents {
var components []string
for _, component := range incident.Components {
components = append(components, component.Name)
}
table.Append([]string{incident.ID, incident.Name, incident.Status, strings.Join(components, ", "), incident.StartedAt, incident.UpdatedAt})
table.Append(incident.ID, incident.Name, incident.Status, strings.Join(components, ", "), incident.StartedAt, incident.UpdatedAt) //nolint:errcheck
}
table.Render()
table.Render() //nolint:errcheck
} else {
fmt.Fprintf(out, "There are no active incidents\n")
}
Expand Down
9 changes: 5 additions & 4 deletions internal/command/orgs/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,14 @@ func runShow(ctx context.Context) (err error) {

fmt.Fprintln(&buf, colorize.Bold("Organization Members"))

membertable := tablewriter.NewWriter(&buf)
membertable.SetHeader([]string{"Name", "Email", "Role"})
membertable := tablewriter.NewTable(&buf,
tablewriter.WithHeader([]string{"Name", "Email", "Role"}),
)

for _, m := range org.Members.Edges {
membertable.Append([]string{m.Node.Name, m.Node.Email, m.Role})
membertable.Append(m.Node.Name, m.Node.Email, m.Role) //nolint:errcheck
}
membertable.Render()
membertable.Render() //nolint:errcheck

buf.WriteTo(io.Out)

Expand Down
4 changes: 2 additions & 2 deletions internal/command/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"

"github.com/kr/text"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"github.com/spf13/cobra"

"github.com/superfly/flyctl/flyctl"
Expand Down Expand Up @@ -232,7 +232,7 @@ func run(ctx context.Context) error {
if err != nil {
panic(err)
}
cmd.Printf(" %s %s\n", tablewriter.PadRight(c.CommandPath(), " ", 16), c.Short)
cmd.Printf(" %s %s\n", tw.PadRight(c.CommandPath(), " ", 16), c.Short)
}

cmd.Println()
Expand Down
15 changes: 6 additions & 9 deletions internal/command/ssh/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,9 @@ func runLog(ctx context.Context) (err error) {
return nil
}

table := tablewriter.NewWriter(out)

table.SetHeader([]string{
"Root",
"Certificate",
})
table := tablewriter.NewTable(out,
tablewriter.WithHeader([]string{"Root", "Certificate"}),
)

for _, cert := range certs {
root := "no"
Expand All @@ -72,7 +69,7 @@ func runLog(ctx context.Context) (err error) {
for i, ch := range cert.Cert {
buf.WriteRune(ch)
if i%60 == 0 && i != 0 {
table.Append([]string{root, buf.String()})
table.Append(root, buf.String()) //nolint:errcheck
if first {
root = ""
first = false
Expand All @@ -82,11 +79,11 @@ func runLog(ctx context.Context) (err error) {
}

if buf.Len() != 0 {
table.Append([]string{root, buf.String()})
table.Append(root, buf.String()) //nolint:errcheck
}
}

table.Render()
table.Render() //nolint:errcheck

return nil
}
Loading