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
Extract table printer from CLI #61
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.
This looks great! Added just a couple non-blocking comments/questions.
example_gh_test.go
Outdated
fmt.Fprintln(os.Stderr, err) | ||
os.Exit(1) |
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 think this is equivalent to log.Fatal(err)
.
pkg/tableprinter/table.go
Outdated
Render() error | ||
} | ||
|
||
// WithTruncate sets the truncation function for the field. Pass nil to disable truncation for this value. |
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 no WithTruncate
function is specified for a field will the the field be truncated as necessary to fit the output 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.
That's a good question! Every field is automatically truncated by default. I will try to point this out in the docs
pkg/term/env.go
Outdated
|
||
// ColorEnabled reports whether it's safe to output ANSI color sequences, depending on IsTerminalOutput and | ||
// environment variables. | ||
func (t Term) ColorEnabled() bool { |
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.
Do we want to name this IsColorEnabled
to match naming scheme of IsTerminalOutput
?
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.
Good idea!
This exposes a TablePrinter that can be used to print column-formatted tabular data to the terminal and the same data in TSV format to redirect to files or scripts.
TODO