Skip to content

feat(cli): render routing list and search as tabular views - #2495

Merged
lgecse merged 3 commits into
agntcy:mainfrom
amalsaidov:feat/2478-tabular-cli-output
Nov 12, 2026
Merged

lgecse merged 3 commits into
agntcy:mainfrom
amalsaidov:feat/2478-tabular-cli-output

Conversation

@amalsaidov

Copy link
Copy Markdown
Contributor

What

The default (human) output of dirctl routing list and dirctl routing search printed the collected records using Go's %v slice form on a single line:

Local records found: [record_ref:{cid:"bafy..."} labels:"/skills/AI" ... record_ref:{cid:"bafy..."} ...]

which is hard to read as soon as there is more than one record (#2478). This renders them as a column-aligned, k8s-style table instead:

CID                       LABELS
bafyreib...               AI, ML
bafyreic...               web-development

search additionally shows the providing peer, match score and the labels that matched. The json, jsonl and raw formats are delegated to the shared presenter and are byte-for-byte unchanged.

How

  • The only tabular renderer in the CLI lived privately in cli/cmd/install (text/tabwriter-based). To avoid inventing a second one, it is extracted into the shared cli/presenter package as Table (NewTable / Row / String) and OrDash, keeping the exact same geometry and behaviour.
  • install is migrated to the shared helper (pure refactor, output unchanged).
  • routing list / routing search build a typed result slice and render it through the new cli/cmd/routing/output.go: a table for human, delegation to presenter.PrintMessage for the structured formats.

This follows the pattern the maintainers already established in the install command rather than introducing a new output abstraction, so it stays focused on the canonical list/search commands and can be extended to other commands incrementally.

How tested

Run inside the cli Go module:

  • go build ./... — passes.
  • go test ./presenter/ ./cmd/routing/ ./cmd/install/ — passes.
    • New presenter tests pin the table alignment and OrDash.
    • New cmd/routing tests cover the human table (list and search), the empty case, and that structured formats still delegate (jsonl stays one compact object per line, no table, no %v leak).
    • Existing install tests confirm the refactor left its output unchanged.
  • go vet ./presenter/ ./cmd/routing/ ./cmd/install/ and gofmt -l — clean.
  • golangci-lint was not available in the environment, so it was not run; the code follows the surrounding conventions (e.g. the //nolint:mnd on the tabwriter geometry carried over from install).

Fixes #2478

🤖 Generated with Claude Code

@amalsaidov
amalsaidov requested a review from a team as a code owner November 10, 2026 21:46
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Nov 10, 2026
@ramizpolic

Copy link
Copy Markdown
Member

Heya @amalsaidov, thanks for the contribution! Could you please fix the lint issues with FIX=true task lint:go?

@lgecse
lgecse force-pushed the feat/2478-tabular-cli-output branch 2 times, most recently from 368702a to c53ec22 Compare November 11, 2026 14:32
amalsaidov and others added 2 commits November 12, 2026 11:00
The default human output for `dirctl routing list` and
`dirctl routing search` printed the collected records with Go's `%v`
slice form on a single line, which is hard to read once there is more
than one record. Switch the default view to a column-aligned, k8s-style
table (CID + labels for list; CID, peer, score and matched labels for
search). The json, jsonl and raw formats are delegated to the shared
presenter unchanged.

The only tabular renderer in the CLI lived privately in the `install`
package. Extract it into the shared `presenter` package as `Table`
(`NewTable`/`Row`/`String`) plus `OrDash`, migrate `install` to the
shared helper, and make `routing` its first additional consumer so the
pattern is reusable by other commands.

Signed-off-by: amalsaidov <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
@lgecse
lgecse force-pushed the feat/2478-tabular-cli-output branch from c53ec22 to 30d42c2 Compare November 12, 2026 10:00
@lgecse lgecse self-assigned this Nov 12, 2026
@lgecse
lgecse force-pushed the feat/2478-tabular-cli-output branch from 8d8a035 to 6322315 Compare November 12, 2026 15:42
@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lgecse
lgecse added this pull request to the merge queue Nov 12, 2026
Merged via the queue into agntcy:main with commit 68e856b Nov 12, 2026
34 checks passed
@amalsaidov

Copy link
Copy Markdown
Contributor Author

Thanks for merging 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve default CLI output format using tabular views

3 participants