-
Notifications
You must be signed in to change notification settings - Fork 382
Make the last col of get-classes and get-plans wider so we're at least 80 cols #2226
Conversation
cmd/svcat/output/class.go
Outdated
@@ -32,16 +32,29 @@ func getClassStatusText(status v1beta1.ClusterServiceClassStatus) string { | |||
|
|||
func writeClassListTable(w io.Writer, classes []v1beta1.ClusterServiceClass) { |
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.
I feel like there's a table writing library we ought to be using.
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.
there is and we're using it. It just doesn't support this feature
8fc428f
to
9e70431
Compare
ping @carolynvs @jberkhahn |
5223376
to
32e637c
Compare
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.
I'm not terribly excited about this as a solution for the description column being too narrow. A couple things that I'd prefer to see:
- Modify
NewListTable()
so that all tables follow this formatting, instead of having to do it one-off for each table. - Provide a function that helps to compute the appropriate size for the last column.
- Understand what this will look like for tables that don't have long last columns. Maybe show an example of this for a broker that doesn't do long descriptions and another that does? Just so we can see what the final result will look like for different use cases.
I thought about how to do some of that stuff. The problem is that if we try to do it "the right way" it'll involve major changes - like creating a proxy structure for each table to track the width of each column as things are appended and calling the proxy for all table ops instead of the real TableWriter. I can take a stab at that but be prepared for a much larger PR with far more impactful changes. I tried to keep things to a minimum with this. |
I'm not so sure about implementing it that way. Who says every single table we write is going to want an extra large last column? How do we know the last column is always going to be the large one? I think implementing it specifically for the output types that actually need large columns seems fine. |
If I did the "right (generic) solution" I was going to make it so that people could tell us which column is the variable/wide one. However, before I head down that path and create a much bigger PR I'd like agreement that we really want the bigger PR and not this more focused one. I'll let you two decide - I can go either way. |
NewListTable is intended to be used for the output of Mostly my objection is that I wouldn't want to ever modify/maintain the code added as it looks right now. It's confusing and I'm hoping that there is a middle ground where at the every least the output functions that want to opt in can do so in a way is consistent and doesn't overwhelm the Write* functions with the logic just to format the width... Honestly I would rather leave it as-is than what's in here. 🤷♀️ |
This new output: https://github.com/kubernetes-incubator/service-catalog/pull/2226/files#diff-345f1d72c94dd1c75d5bf43421aa41e2L1 shows why I really want something like this. The old format made us looks silly. |
Ah, ok. I think the best solution then would be to write some function that figures this out in a generic manner, and then call out to it from writeClassListTable and writePlanListTable |
I don't see anything convincing in #2226 (comment) . Looks fine to me both before and after. I like the consistency of after and the compactness of before This needs a test and example with some long lines. |
…t 80 cols Signed-off-by: Doug Davis <dug@us.ibm.com>
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.
typos
cmd/svcat/output/table.go
Outdated
const DEFAULT_PAGE_WIDTH = 80 | ||
|
||
// ListTable is a proxy for tablewriter.Table so we can support variable a | ||
// width column that tries to full up extract space. |
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.
full -> fill
extract -> exact
I think
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.
yup fixed
cd1940b
to
193c22e
Compare
@carolynvs see if you like this version better. If so, I'll squash to kill-off the first variant. |
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.
This is exactly what I was hoping for! Just one small change, I think that we can cut down on those middleman methods.
t.SetHeader([]string{ | ||
"Name", | ||
"Namespace", | ||
"Description", | ||
}) | ||
t.SetVariableColumn(3) |
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.
❤️ Thanks, this is exactly what I was hoping for!
@@ -22,12 +22,124 @@ import ( | |||
"github.com/olekukonko/tablewriter" | |||
) | |||
|
|||
// DefaultPageWidth is the page (screen) width to use when we need to twiddle |
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.
I am pro "twiddling" 👍
cmd/svcat/output/table.go
Outdated
// value of our special column first, call SetColMinWidth and then add the | ||
// headers/rows. | ||
type ListTable struct { | ||
table *tablewriter.Table |
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.
If you make table
an embedded field field instead of a named field, i.e. change this line to *tablewriter.Table
without the name, then you don't need to implement the passthrough functions, like SetBorder
.
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.
thought about that, but I'm not sure how to do super.Append()
when I have my own Append()
because I need to override it.
53becd4
to
c22d950
Compare
@duglin I pushed a commit to your branch that shows what I was suggesting. |
cmd/svcat/output/table.go
Outdated
@@ -37,26 +37,19 @@ const DefaultPageWidth = 80 | |||
// value of our special column first, call SetColMinWidth and then add the | |||
// headers/rows. | |||
type ListTable struct { | |||
table *tablewriter.Table | |||
*tablewriter.Table |
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.
Interesting, I forgot you could ref it by "Table" later on like that. This is why I still feel like such a newbie w.r.t. golang - thanks!
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.
Using embedded fields to satisfy an interface is a really nice feature! 👍
Sorry about pushing to your fork! Next time I send a gist or patch.
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.
No worries, just a "you dunce, just refer it to by Table
" would have gotten the point across ;-)
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.
/lgtm
Looks like you fixed Morgan's comment, LGTM. |
cmd/svcat/output/table.go
Outdated
@@ -22,12 +22,118 @@ import ( | |||
"github.com/olekukonko/tablewriter" | |||
) | |||
|
|||
// DefaultPageWidth is the page (screen) width to use when we need to twiddle | |||
// the width of some table columns for better viewing. For now assume its only |
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.
its -> it's
cmd/svcat/output/table.go
Outdated
lt.Table.SetHeader(keys) | ||
} | ||
|
||
// Append will look at each column in the row to see if its longer than any |
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.
its -> it's
or
it is
cmd/svcat/output/table.go
Outdated
|
||
// If this column doesn't push us past the page width then just | ||
// set it to the max cell width so Render() doesn't chop it on us. | ||
// Otherwise, chop it so we don't go page the page width. |
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.
past the page width
Signed-off-by: Doug Davis <dug@us.ibm.com>
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MHBauer The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Doug Davis dug@us.ibm.com