Skip to content

fix: Match kubectl table style for simpler scripting #1363

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

Merged
merged 1 commit into from
May 10, 2022
Merged

Conversation

kylecarbs
Copy link
Member

@kylecarbs kylecarbs commented May 10, 2022

Fixes #1322.

image

@kylecarbs kylecarbs requested review from coadler and deansheather May 10, 2022 16:31
@kylecarbs kylecarbs self-assigned this May 10, 2022
@codecov
Copy link

codecov bot commented May 10, 2022

Codecov Report

Merging #1363 (6e65e6f) into main (b675aec) will increase coverage by 0.32%.
The diff coverage is 54.45%.

@@            Coverage Diff             @@
##             main    #1363      +/-   ##
==========================================
+ Coverage   66.69%   67.01%   +0.32%     
==========================================
  Files         284      287       +3     
  Lines       18614    18762     +148     
  Branches      235      235              
==========================================
+ Hits        12414    12573     +159     
+ Misses       4931     4902      -29     
- Partials     1269     1287      +18     
Flag Coverage Δ
unittest-go-macos-latest 54.22% <54.45%> (+0.33%) ⬆️
unittest-go-postgres- 65.61% <54.45%> (+0.21%) ⬆️
unittest-go-ubuntu-latest 56.62% <54.45%> (+0.32%) ⬆️
unittest-go-windows-2022 52.54% <54.45%> (+0.17%) ⬆️
unittest-js 73.67% <ø> (ø)
Impacted Files Coverage Δ
cli/templatelist.go 10.81% <0.00%> (+0.81%) ⬆️
cli/list.go 47.05% <47.36%> (+37.53%) ⬆️
cli/cliui/table.go 48.00% <48.00%> (ø)
cli/root.go 79.72% <100.00%> (+0.28%) ⬆️
cli/userlist.go 82.85% <100.00%> (+13.89%) ⬆️
coderd/workspaceagents.go 56.04% <0.00%> (-1.87%) ⬇️
codersdk/users.go 63.79% <0.00%> (-0.62%) ⬇️
peer/conn.go 79.60% <0.00%> (-0.50%) ⬇️
codersdk/client.go 59.74% <0.00%> (ø)
codersdk/templates.go 60.37% <0.00%> (ø)
... and 14 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b675aec...6e65e6f. Read the comment docs.


// Table creates a new table with standardized styles.
func Table() table.Writer {
tableWriter := table.NewWriter()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to bikeshed on this, but Go had a stdlib solution for this: https://pkg.go.dev/text/tabwriter. Haven't taken a look at this package though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually nvm, I thought u were totally switching out the table packages

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, nah. This package handles hiding columns and sorting which is kinda nice.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye i agree, should've looked through more b4 commenting

Comment on lines +49 to +50
cmd.Flags().StringArrayVarP(&columns, "column", "c", nil,
"Specify a column to filter in the table.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To filter by multiple columns, do you need to specify the flag multiple times? Or can it accept a comma delimited string? I think we should document how to specify multiple.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to specify multiple, but the flag does specify the type as doing so.

@kylecarbs kylecarbs merged commit e0a7aec into main May 10, 2022
@kylecarbs kylecarbs deleted the listfmt branch May 10, 2022 20:57
@misskniss misskniss added this to the V2 Beta milestone May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal "niceties" make it difficult to script coder
3 participants