Skip to content

Fit table output to the terminal width - #72

Merged
weppos merged 3 commits into
mainfrom
long-text-display-185595
Aug 24, 2026
Merged

Fit table output to the terminal width#72
weppos merged 3 commits into
mainfrom
long-text-display-185595

Conversation

@weppos

@weppos weppos commented Aug 24, 2026

Copy link
Copy Markdown
Member

Table output is now cut to the width of the terminal. A long value, for example a DNSKEY record, padded the CONTENT cell of every row and pushed the TTL and the REGIONS columns off the screen, so one long value broke the alignment of the whole table. The columns before the last one now shrink to fit, and a value that does not fit ends with .... The last column never shrinks, because tabwriter does not pad the last cell of a row.

Only a terminal cuts the table. Redirected output, --json, --format, and the single-resource get commands still return the full value.

Closes #13

🔍 QA

Scenario: List the records of a signed zone

  • Run dnsimple records list <zone> on a zone that has DNSKEY records.
  • Confirm the table fits the window, each long value ends with ..., and the TTL and the REGIONS columns stay on the same line as their record.
  • Make the window narrower and run the command again. Confirm the cut follows the new width.
  • Run dnsimple records list <zone> | cat. Confirm the output carries the full values.
  • Run dnsimple records get <zone> <record-id> for a DNSKEY record. Confirm the detail table shows the full content.

📋 Deployment Pre/Post tasks

N/A

:shipit: Deployment Verification

N/A

tabwriter sizes a column by its widest cell, so a 400 character DNSKEY
value padded the CONTENT cell of every row and pushed TTL and REGIONS
past the right edge of the screen. One long value broke the alignment of
the whole table.

The columns before the last one now shrink to fit the terminal, and a
value that no longer fits ends with an ellipsis. The last column never
shrinks, because tabwriter does not pad the last cell of a row. A writer
that is not a terminal keeps every value in full, so a pipe, a redirect,
--json, and --format stay lossless.
@weppos weppos self-assigned this Aug 24, 2026
@weppos weppos added the enhancement New feature, enhancement or code changes, not related to defects label Aug 24, 2026
weppos added 2 commits August 24, 2026 12:59
A last column wider than the terminal never shrinks, so the columns
before it were giving up their values for nothing. The FIELD labels of a
detail table were cut to "Syste..." while the value they describe stayed
whole. Leave the table alone in that case, and skip the row copy when the
table already fits.

Fold the terminal probe into terminalWidth next to IsTerminal, so the
*os.File assertion has one home, and count runes with the standard
library instead of a local helper.
The last column test used a FIELD label of seven characters, which is
under the floor and can never be cut. It passed whatever the code did.
@weppos
weppos merged commit 82e9c4b into main Aug 24, 2026
8 checks passed
@weppos
weppos deleted the long-text-display-185595 branch August 24, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature, enhancement or code changes, not related to defects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve how DNS records are displayed

1 participant