Commit 9f7b3df
Skip column truncation when stdout is piped (non-TTY) (#148)
## Summary
Fixes CLI table output truncation when stdout is piped to other tools
(grep, awk, cat, etc.).
**Before:** `kernel browsers list | grep hype` returned nothing because
URLs and other columns were truncated even in pipe mode.
**After:**
- TTY (interactive terminal): columns truncate to fit terminal width
(unchanged)
- Non-TTY (piped): full column values output without truncation
This follows the standard CLI pattern used by `docker ps`, `kubectl
get`, etc.
### Changes
- `pkg/table/table.go`: Skip `truncateTableData` when stdout is not a
TTY; add `IsStdoutTTY()` helper
- `cmd/browsers.go`: `truncateURL` skips truncation in non-TTY mode
## Test plan
- [ ] `kernel browsers list` in terminal — columns still truncate to fit
width
- [ ] `kernel browsers list | cat` — full URLs visible, no truncation
- [ ] `kernel browsers list | grep <pattern>` — matches found in full
output
- [ ] All existing tests pass (`go test ./...`)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk: changes are limited to CLI formatting behavior and only
affect output when stdout is not a terminal (piped), with no impact on
API calls or data mutation.
>
> **Overview**
> Stops truncating CLI output when stdout is piped (non-TTY) so full
column values are preserved for tools like `grep`/`awk`.
>
> `pkg/table.PrintTableNoPad` now truncates columns only for terminal
output and adds a shared `table.IsStdoutTTY()` helper;
`cmd/browsers.go`’s `truncateURL` also skips truncation when not on a
TTY.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
b003810. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Co-authored-by: sjmiller609 <7516283+sjmiller609@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 6d54518 commit 9f7b3df
2 files changed
Lines changed: 19 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
3256 | 3257 | | |
3257 | 3258 | | |
3258 | 3259 | | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
3259 | 3263 | | |
3260 | 3264 | | |
3261 | 3265 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | | - | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| |||
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
93 | 103 | | |
94 | 104 | | |
95 | 105 | | |
| |||
0 commit comments