Coming from shared/cmd: Modernize table look by bensmrs · Pull Request #3907 · lxc/incus · GitHub.
Issue is that Incus CLI doesn’t adapt to the width of the terminal. This can severly impact table display for example:
Quick solutions here can include piping the output to less -S, necessitating horizontal scrolling.
Printing effectively the same table with glow results in this, defaulting to width of 80:
Other CLI markdown renderers like rich-cli or bat are relevent, I however tested all these in a project of mine with very similar issue in mind and glow won. And it’s in Go which is favorable.
Glow’s small limitation is that it doesn’t automatically infer terminal width so that must be done on the caller side. Regardless, with somewhat larger width (-w 120):
Here is also a different set of tables rendered with glow:
So reimplementing their approach could be a thing.
But, I think delegating the rendering to them (and outputting actual markdown) is more interesting. Either via dynamic discovery of the glow CLI tool and piping or via direct optional dependency and wiring up the code.
I for one prefer paged output by default for CLI tools (even if the text fits vertically), glow can facilitate that as well.
However, it’s a big step to just transition to markdown outputs, opt-in or otherwise, nonetheless I wanted to put this issue in better perspective.
Source markdown tables:
incus list
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
|-|-|-|-|-|-|
| test-1 | RUNNING | 10.154.183.103 (eth0) | fd42:ba06:7488:e415:a3cb:53dd:bfd4:8fc2 (eth0) fd42:ba06:7488:e415:216:3eff:fe77:bd54 (eth0) | CONTAINER | 0 |
| test-2 | STOPPED | | | CONTAINER | 0 |
test
| Feature | Status | Score |
|:--------|:------:|------:|
| Dark mode | Yes | 95 |
| SSO | No | 0 |
| Feature | Status | Score | Score | Score | Score | Score | Score | Score | Score | Score | Score | Score | Score |
|:--------|:------:|------:|------:|------:|------:|------:|------:|------:|------:|------:|------:|------:|------:|
| Dark mode | Yes | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 | 95 |
| SSO | No | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 2 | 3 |
|---------|---------------------|---------------|
| Bold | `**bold**` | **bold** |
| Italic | `*italic*` | *italic* |
| Code | ``code`` | `code` |
| Link | `[text](url)` | [Docs](https://example.com) |
| Long text | Standard inline Markdown (bold, italic, code, links) works inside table cells. The only exception is block-level elements like blockquotes and multi-line code blocks, which are ignored inside tables by most renderers. | - |



