Skip to content
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

Merged
merged 1 commit into from Aug 9, 2022
Merged

Extract table printer from CLI #61

merged 1 commit into from Aug 9, 2022

Conversation

mislav
Copy link
Contributor

@mislav mislav commented Aug 2, 2022

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

  • more tests
  • API docs

Copy link
Contributor

@samcoe samcoe left a 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.

Comment on lines 185 to 186
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
Copy link
Contributor

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).

Render() error
}

// WithTruncate sets the truncation function for the field. Pass nil to disable truncation for this value.
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea!

@mislav mislav merged commit 853b6a5 into trunk Aug 9, 2022
@mislav mislav deleted the tableprinter branch August 9, 2022 15:27
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.

None yet

2 participants