-
Notifications
You must be signed in to change notification settings - Fork 0
Generic table output #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request introduces a reusable table printer utility to standardize and simplify tabular output across CLI commands. Previously, each command manually calculated column widths and formatted output, leading to code duplication and inconsistent formatting.
- Introduces a new
internal/tablepackage with dynamic column width calculation - Refactors six CLI commands (
instance_list,instance_nodes,instance_plugins,plans,team_list,vpc_list) to use the new table printer - Enhances output with new columns (roles and 2FA status in team listing, VPC ID, improved plan price formatting)
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/table/table.go | New table printer utility with automatic width calculation and formatted output |
| internal/table/table_test.go | Unit tests for table printer functionality including alignment and error handling |
| cmd/instance_list.go | Replaces manual table formatting with table printer, reducing code from ~50 to ~15 lines |
| cmd/instance_nodes.go | Adopts table printer for node listing with improved disk size formatting |
| cmd/instance_plugins.go | Uses table printer for plugin listing output |
| cmd/plans.go | Switches from JSON output to formatted table with price and sharing information |
| cmd/team_list.go | Adds new ROLES and 2FA columns using table printer |
| cmd/vpc_list.go | Adds VPC ID column and uses table printer for consistent formatting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
In response to the Copilot comments on checking the Error returned by AddRow: We control both the table creation AND the row additions - they're in the same function, just a few lines apart |
This pull request refactors the way tabular data is printed in several CLI commands by introducing a new reusable table printer utility. Previously, each command manually calculated column widths and formatted output using
fmt.Printf. Now, all commands use the newtablepackage for dynamic and consistent table formatting, improving maintainability and output readability.Table printing improvements:
internal/table/table.goutility, which provides aPrintertype for dynamic column width calculation and formatted output, along with a corresponding test suite ininternal/table/table_test.go. [1] [2]Refactoring CLI commands to use the new table printer:
cmd/instance_list.go,cmd/instance_nodes.go,cmd/instance_plugins.go,cmd/plans.go,cmd/team_list.go, andcmd/vpc_list.goto replace manual table formatting with the new table printer, resulting in cleaner and more consistent code. [1] [2] [3] [4] [5] [6] [7]Codebase modernization:
osand the newtablepackage to affected files, removing unused imports such asencoding/jsonwhere appropriate. [1] [2] [3] [4] [5] [6]Output consistency and feature enhancements:
Testing: