Make CLI automatically switch from aligned to vertical format#12208
Make CLI automatically switch from aligned to vertical format#12208kokosing merged 1 commit intotrinodb:masterfrom
Conversation
3550adc to
217c6de
Compare
|
This is the equivalent of |
hashhar
left a comment
There was a problem hiding this comment.
The feature and implementation seems good to me.
The env var seems overkill to me. What use-case did you have in mind?
It's required so that users (well, I mostly ;-) can have it turned on by default, without changing the current default output (aligned). There's no RC file like in PostgreSQL. Without this, it defeats the purpose of it being automatic if I'd have to remember to turn it on on every invocation. |
|
Let's discuss about having a config file then, it seems like a good change IMO since it'll make it much easier to support things like not having to enter lengthy arguments for Kerberos or self-signed tls auth etc. as well instead of just being specific to this single feature. cc: @electrum @findepi WDYT about a config file to read some defaults for configs from? Would make using the CLI a lot easier. |
|
@hashhar would it be enough to read a properties file from the user's home dir? https://picocli.info/#_propertiesdefaultprovider |
ceff83a to
e457c2a
Compare
|
All done, I added reading a config file as the first commit. I also added two new options for the pager and history file, so they also can be configured via the file, not only as environmental variables, for consistency. The second commit adds the new AUTO format but also allows to configure the output format in the interactive mode. @mosabua I requested a review from you because I made doc changes but let's first wait to get the code changes approved. |
837dab7 to
3c43e40
Compare
|
@hashhar I removed the new env var for output format but changing the default in the config file means it'll apply to both interactive and batch modes. I'm thinking about adding yet another flag for interactive mode, but |
3d31785 to
474914f
Compare
474914f to
1c754fe
Compare
27d377f to
c7af831
Compare
c7af831 to
a7a328f
Compare
|
@dain maybe you'd like to review this one? |
|
Could we get this reviewed by whoever necessary and merged? |
a7a328f to
167fbe4
Compare
|
@electrum can you PTAL? |
|
I think this is a good feature to add. |
|
@kokosing WDYT? |
kokosing
left a comment
There was a problem hiding this comment.
I like this change. I think it is also safe to merge as it does not change any existing functionality, but adds new one.
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
client/trino-cli/src/main/java/io/trino/cli/AutoTablePrinter.java
Outdated
Show resolved
Hide resolved
2395382 to
69ee34e
Compare
69ee34e to
76f5b01
Compare
|
@kokosing this is ready to go, PTAL. |
|
@nineinchnick I also think this is useful. I have faced this problem where there are too many columns, until now I have been using |
|
Thanks |
Description
Make CLI automatically switch from aligned to vertical format when the output wouldn't fit the current terminal's width. Currently, users can terminate the query with
\G, but this has a few drawbacks:SHOW FUNCTIONSwhere the second column is so wide you might not notice there are moreGhas to be upper-caseThis PR introduces a new
AUTOoutput format that automatically switches fromALIGNEDtoVERTICALif the aligned table is wider than the current terminal. But it doesn't make the auto format the default, for backward compatibility. Users need to enable it by using--output-format-interactive=AUTOor by adding it to the config file.improvement
cli
Add a new
AUTOoutput format to the CLI client, that switches fromALIGNEDtoVERTICALif the output wouldn't fit the current terminal.Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
(x) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: