Skip to content

Commit 19e3451

Browse files
feat: make CLI tables responsive (#79)
* feat: make CLI tables responsive * fix: preallocate sandbox list table
1 parent 713e82b commit 19e3451

27 files changed

Lines changed: 360 additions & 40 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ createos sandbox create --shape s-1vcpu-1gb --name my-box --ssh-key ~/.ssh/id_ed
536536
createos sandbox create --shape s-1vcpu-512mb --ingress --auto-pause 1h
537537
createos sandbox list
538538
createos sandbox list --all
539+
createos sandbox list --wide
539540
createos sandbox list --status paused --quiet | xargs createos sandbox rm --force
540541
createos sandbox get <id>
541542
createos sandbox exec my-box -- uname -a

cmd/cronjobs/activities.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func newCronjobsActivitiesCommand() *cli.Command {
7171
log,
7272
})
7373
}
74-
_ = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render() //nolint:errcheck
74+
_ = output.RenderTable(tableData) //nolint:errcheck
7575
fmt.Println()
7676
})
7777
return nil

cmd/cronjobs/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func newCronjobsListCommand() *cli.Command {
5353
cj.CreatedAt.Local().Format("2006-01-02 15:04:05"),
5454
})
5555
}
56-
_ = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render() //nolint:errcheck
56+
_ = output.RenderTable(tableData) //nolint:errcheck
5757
fmt.Println()
5858
})
5959
return nil

cmd/deployments/helpers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/NodeOps-app/createos-cli/internal/api"
1010
"github.com/NodeOps-app/createos-cli/internal/cmdutil"
11+
"github.com/NodeOps-app/createos-cli/internal/output"
1112
"github.com/NodeOps-app/createos-cli/internal/terminal"
1213
)
1314

@@ -82,7 +83,7 @@ func pickDeployment(client *api.APIClient, projectID string, statusFilter []stri
8283
})
8384
}
8485
fmt.Println()
85-
if err = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
86+
if err = output.RenderTable(tableData); err != nil {
8687
pterm.Error.Println("could not display table")
8788
}
8889
fmt.Println()

cmd/deployments/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func newDeploymentsListCommand() *cli.Command {
5050
d.CreatedAt.Local().Format("2006-01-02 15:04:05"),
5151
})
5252
}
53-
if err := pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
53+
if err := output.RenderTable(tableData); err != nil {
5454
pterm.Error.Println("could not display table")
5555
}
5656
})

cmd/domains/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/NodeOps-app/createos-cli/internal/api"
1010
"github.com/NodeOps-app/createos-cli/internal/cmdutil"
11+
"github.com/NodeOps-app/createos-cli/internal/output"
1112
)
1213

1314
func newDomainsCreateCommand() *cli.Command {
@@ -82,6 +83,6 @@ func printDNSRecords(d api.Domain) {
8283
tableData = append(tableData, []string{"TXT", txt.Name + "." + d.Name, txt.Value})
8384
}
8485

85-
_ = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render() //nolint:errcheck
86+
_ = output.RenderTable(tableData) //nolint:errcheck
8687
fmt.Println()
8788
}

cmd/domains/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func newDomainsListCommand() *cli.Command {
7070
}
7171
tableData = append(tableData, []string{d.ID, d.Name, env, icon + " " + d.Status, msg})
7272
}
73-
_ = pterm.DefaultTable.WithHasHeader().WithData(tableData).Render() //nolint:errcheck
73+
_ = output.RenderTable(tableData) //nolint:errcheck
7474
fmt.Println()
7575
})
7676
return nil

cmd/env/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func newEnvListCommand() *cli.Command {
5757
tableData = append(tableData, []string{k, val})
5858
}
5959

60-
if err := pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
60+
if err := output.RenderTable(tableData); err != nil {
6161
return err
6262
}
6363
fmt.Println()

cmd/environments/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func newEnvironmentsListCommand() *cli.Command {
6262
env.CreatedAt.Local().Format("2006-01-02 15:04:05"),
6363
})
6464
}
65-
if err := pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
65+
if err := output.RenderTable(tableData); err != nil {
6666
pterm.Error.Println("could not display table")
6767
}
6868
fmt.Println()

cmd/oauth/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func newListCommand() *cli.Command {
4040
item.CreatedAt.Local().Format("2006-01-02 15:04:05"),
4141
})
4242
}
43-
if err := pterm.DefaultTable.WithHasHeader().WithData(tableData).Render(); err != nil {
43+
if err := output.RenderTable(tableData); err != nil {
4444
pterm.Error.Println("could not display table")
4545
}
4646
fmt.Println()

0 commit comments

Comments
 (0)