Skip to content

feat: CLI output overhaul and bug fixes#13

Merged
eskp merged 1 commit into
mainfrom
feature/cli-output-overhaul
Mar 13, 2026
Merged

feat: CLI output overhaul and bug fixes#13
eskp merged 1 commit into
mainfrom
feature/cli-output-overhaul

Conversation

@eskp
Copy link
Copy Markdown
Contributor

@eskp eskp commented Mar 13, 2026

Summary

  • Overhauls the CLI output system to match gh CLI conventions: tab-delimited piped output, key:value detail views, relative timestamps, colored status columns, and empty state messages
  • Fixes 5 bugs: --host flag ignored by all commands, workflow run 200/202, org members 404, --limit ignored, macOS keychain prompts
  • Adds --web flag for opening resources in browser, .mcp.json for kh serve --mcp, and new Printer helpers (PrintKeyValue, PrintDryRun)

Bug fixes

  • --host flag: All 30+ commands now use cmdutil.ResolveHost(cmd, cfg) instead of hardcoded cfg.DefaultHost
  • org members 404: Changed from POST /get-full-organization to GET /list-members (correct Better Auth endpoint)
  • workflow run 200/202: Accepts both status codes from server
  • --limit flag: Client-side slice fallback when server doesn't support ?limit
  • macOS keychain: FileBackend prioritized over KeychainBackend in keyring.go

Output system

  • internal/output/table.go: Non-TTY returns tsvWriter (tab-separated, no headers, no borders) so kh wf ls | cut -f2 works
  • internal/output/printer.go: PrintKeyValue for detail views, PrintDryRun for dry-run mode
  • internal/output/timeago.go: Relative timestamps (18d ago, 35m ago) for table mode
  • internal/output/color.go: ANSI green/red/yellow for status values in TTY mode
  • internal/output/truncate.go: String truncation helpers

Test plan

  • go test ./... passes (26 packages, 0 failures)
  • go build succeeds
  • E2E tested against localhost:3000 dev server
  • Verified: workflow list/get/run/pause, org list/members/switch, project/tag/template list, run status/logs/cancel, auth status, doctor, billing, --json, --jq, --web, --host, --limit, piped output with cut

Output system:
- Tab-delimited non-TTY output for pipe compatibility (cut, awk, etc.)
- Key:value detail views instead of box tables for single-object commands
- Relative timestamps in table mode (18d ago, 35m ago)
- Colored status columns (green/red/yellow) in TTY mode
- Empty state messages instead of empty bordered tables
- String truncation helpers for long cell values

Bug fixes:
- --host flag now respected by all commands via cmdutil.ResolveHost
- workflow run accepts both HTTP 200 and 202
- org members uses GET /list-members (was POST to wrong endpoint)
- --limit flag works client-side as server fallback
- FileBackend prioritized over KeychainBackend to avoid macOS prompts

Features:
- --web flag on workflow get opens resource in browser
- .mcp.json for kh serve --mcp integration
- PrintKeyValue and PrintDryRun methods on Printer
@eskp eskp merged commit 6c9fc3f into main Mar 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant