Skip to content

Dynamically adjust table column widths in zfs-info output#19

Merged
weak-head merged 1 commit into
mainfrom
feature/align-info
Mar 14, 2026
Merged

Dynamically adjust table column widths in zfs-info output#19
weak-head merged 1 commit into
mainfrom
feature/align-info

Conversation

@weak-head
Copy link
Copy Markdown
Owner

Description

This PR improves the readability of the zfs-info command output by replacing hardcoded column widths with dynamic, data-driven sizing.

Motivation and Context

Previously, the awk script used fixed-width formatting (e.g., %-30s) defined in the BEGIN block. If a dataset name, AWS bucket, or replication target string exceeded these fixed limits, the table layout would break or become misaligned. Conversely, short values left excessive empty space. This update ensures the table is always perfectly aligned based on the actual data being presented.

Changes Proposed

  • Moved the header and separator generation to the END block so the script can evaluate the entire dataset first.
  • The script now calculates the maximum string length for each specific column, factoring in the header lengths as the baseline.
  • Automatically adds a 4-space padding to the maximum calculated width of each column for consistent spacing.
  • Dynamic separator line: The horizontal separator (---) is now programmatically generated to match the exact total width of the new dynamic table.

@weak-head weak-head added this to the 0.3.0 milestone Mar 14, 2026
@weak-head weak-head self-assigned this Mar 14, 2026
@weak-head weak-head added the enhancement Includes general improvements or feature changes and select new feature requests label Mar 14, 2026
@weak-head weak-head merged commit 4b38b15 into main Mar 14, 2026
2 checks passed
@weak-head weak-head deleted the feature/align-info branch March 14, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Includes general improvements or feature changes and select new feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant