Tabular data

Format of the table

Each row should not be more than 80 characters (including the column delimiting spaces).

Use two spaces as a column delimiter.

Column headers are usually left-aligned.

Column headers should use title case (e.g. Name Status etc).

Columns containing numbers that can be compared should be right-aligned, the column headers should, also be right aligned.

  • Don’t
    image

  • Do
    image

If tty is present

You may reduce the amount of duplication present, by utilising white space. This is not a substitute for an empty cell. It is used if you’ve got the exact same content in multiple rows one under the other.

You should not provide ASCII decorations, e.g. lines, to delimit columns.

You may use spaces within cells to provide more easily readable output.

Only show a few columns by default but allow the user to pass --columns with a comma-separated list of column names to add less common types.

Truncate rows that are going to spill over the current screen width unless --no-truncate is set.

Show column headers by default but allow them to be hidden with --no-headers.

If tty is not present

Instead of white/empty space when data is missing, use a single dash (-) in that cell.

If there is information that might be formatted strangely or not always be present, you may use a column called “Notes” as a catch-all. Always have this column be the last one.

Do not use spaces within table cells unless absolutely necessary. Spaces are reserved for delimiting columns. If displaying date/time data, you can use a capital T between the date and the time to indicate where the time string starts.

Examples:
image


tty vs piped output:

1 Like