Skip to content

refactor: print each lodgectl list table with one helper - #60

Merged
bketelsen merged 2 commits into
mainfrom
groom/lodgectl-tables
Nov 11, 2026
Merged

bketelsen merged 2 commits into
mainfrom
groom/lodgectl-tables

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

cmd/lodgectl/main.go had 7 functions (showUsage, showApps, showLogins, showNodes, showTokens, showSessions, showModels) that repeat one pattern: decode a JSON list, make 1 row per item, print the table. This PR adds 1 generic helper, showList[T], and each of the 7 functions becomes a call to it with its header and its row function. The names, the signatures, the headers, the cells and their order stay the same, so parse does not change.

No change in behavior: the same stdout for every list command, the same decode error, and the same --json output (which does not use these functions).

Left out on purpose: cmd/lodgectl/login.go (a risk path) and the local cmp helper, which login.go also uses; showStatus, showDone, showIssued and showImported, which do not print a list.

Risk tier

Risk tier: 1 — a refactor of the CLI's table printing with no change in behavior; no path in .github/risk-paths.json is touched.

Verification

  • Commit 1 (b5f3d08) adds cmd/lodgectl/show_test.go, characterization tests that pin the exact stdout of all 7 tables (2 rows each, - cells, empty lists) and their decode error. On the base code: go test -count=1 ./cmd/lodgectl/ → ok (0.072s).
  • Commit 2 (18aa34f) is the refactor. The existing tests and the new ones are unchanged.
  • make check green (host): on the base 74a31e4, exit 0; on the head 18aa34f, exit 0.

Cross-review

  • Reviewer openai/gpt-6.1-sol; coder deepseek/deepseek-flash.
  • Base 74a31e4856b5e44da4567c53307cb83cf1354bf1, head 18aa34f899bbf829af18941c6064eabb1c61ef3b; 1 pass, both changed files.
  • Question: "Does any line of this diff change observable behavior?" Answer: no; all 7 functions keep their names, signatures, headers, cells, order and decode error.
  • Result: Ready, Blocking: none, 0 findings.
  • Revert test: exempt (a pure refactor; the proof is the same tests green on the base and the head).

@github-actions github-actions Bot added the level:L3 Skim label Nov 11, 2026
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 11, 2026
@bketelsen
bketelsen merged commit 701cb0b into main Nov 11, 2026
11 checks passed
@bketelsen
bketelsen deleted the groom/lodgectl-tables branch November 11, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L3 Skim ready-for-human Reviewed, CI green: ready for Brian to review and merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants