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

feat: support custom column widths in cli #4616

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

colinhicks
Copy link
Contributor

Description

Allow column width to be explicitly specified in tabular cli output. By default, column width is determined based on the terminal width and the number of columns. With these changes, the width of each column may be optionally overridden:

ksql> SET CLI COLUMN-WIDTH 10

Given a customized value, subsequent renderings of output use the setting:

ksql> SELECT * FROM riderLocations
>  WHERE GEO_DISTANCE(latitude, longitude, 37.4133, -122.1162) <= 5 EMIT CHANGES;
+----------+----------+----------+----------+----------+
|ROWTIME   |ROWKEY    |PROFILEID |LATITUDE  |LONGITUDE |
+----------+----------+----------+----------+----------+

The default behavior can be re-enabled using:

ksql> SET CLI COLUMN-WIDTH 0

Testing done

Existing and added unit tests
Built Docker image and smoke tested

resolves #4141

Reviewer checklist

  • Ensure docs are updated if necessary. (eg. if a user visible feature is being added or changed).
  • Ensure relevant issues are linked (description should include text like "Fixes #")

@colinhicks colinhicks requested a review from a team as a code owner February 24, 2020 22:40
@ghost
Copy link

ghost commented Feb 24, 2020

@confluentinc It looks like @colinhicks just signed our Contributor License Agreement. 👍

Always at your service,

clabot

Copy link
Member

@spena spena left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -27,6 +27,7 @@
public class CliConfig extends AbstractConfig {

public static final String WRAP_CONFIG = "WRAP";
public static final String COLUMN_WIDTH_CONFIG = "COLUMN-WIDTH";
Copy link
Contributor

Choose a reason for hiding this comment

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

for what it's worth, postgres does:

postgres=# \pset columns 20
Target width is 20.

I think COLUMN-WIDTH is easier to understand, but just something to note.

@colinhicks colinhicks merged commit 42282cd into confluentinc:5.5.x Feb 25, 2020
@colinhicks colinhicks deleted the GH-4141-cli-col-width branch February 25, 2020 20:34
@colinhicks colinhicks added this to the 0.7.1 milestone Feb 26, 2020
colinhicks added a commit that referenced this pull request Feb 27, 2020
Allow column width to be explicitly specified in tabular cli output, e.g.: 
ksql> SET CLI COLUMN-WIDTH 10

Given a customized value, subsequent renderings of output use the setting.

The default behavior, in which column width is determined based on the terminal width and column count, can be re-enabled using:
ksql> SET CLI COLUMN-WIDTH 0
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.

3 participants