Normalize output-format parsing and rendering across builtin commands - #190
Normalize output-format parsing and rendering across builtin commands#190Sneh30 wants to merge 12 commits into
Conversation
… webcmd-usage skill
🟢 No documentation gap found — medium confidenceThe automated review found no documentation gap in the supplied changes. This review is advisory and does not block merging. |
|
Thanks for the PR! A few changes I'd like before this lands:
Nits
The tests look well targeted. I especially liked inverting the existing |
Validate -f/--format in the hosted list, profile, and plugin search command surfaces through the shared parseOutputFormat, matching the local CLI. Unsupported values now fail with a usage error (exit code 2) instead of silently rendering a table, and aliases/case are normalized the same way everywhere. BREAKING CHANGE: `-f/--format` values other than `table`, `plain`, `json`, `yaml`, `md`, or `csv` now fail with a usage error (exit code 2) instead of silently rendering a table. This applies to builtin commands, adapter commands, and is now enforced consistently by hosted `list`, `profile`, and `plugin search` too.
Pass the explicit-format source through to the webcmd list renderer for consistency with the other list handlers; table output never reaches the renderer, but this closes the remaining handler that omitted fmtExplicit.
Document that plugin list always renders its human-friendly grouped listing when the effective format is table (default or explicit, TTY or not), recommend -f json/-f yaml for machine-readable output, and note the unsupported-format usage error.
|
Thanks for the thorough review — all the feedback has been addressed. On the squash request, I'd like to keep the branch as-is if that's acceptable; the commits are already logically separated (feature, per-family fixes, tests, docs) and the review comments are covered by four small follow-ups. If you'd prefer a single commit in Point-by-point:
Nits:
Tests: |
What
Fixes #172: unify
-f/--formatparsing and rendering so every builtin command accepts and honors the same set of output formats, rejects unsupported values, and emits consistent structured output.Single source of truth
src/command-surface.tsnow owns the canonical formats (table,plain,json,yaml,md,csv), the aliasesyml → yamlandmarkdown → md, the shared help text, and theparseOutputFormat/resolveOutputFormatvalidators (case-insensitive).-f/--formatflags (builtin commands,auth status/refresh, adapter/hosted surfaces) advertise the same format list.Behavior fixes
plugin list -f yamlnow emits real YAML (previously a table); emptyplugin list -f jsonemits[]instead of human guidance.skills list,external list,plugin catalog list/add,plugin search,convention-audit, andauth status/refreshnow honor all six formats with the correct explicit/implicit semantics (table in TTY, YAML outside TTY unless-fis given).webcmd list,skills list,convention-audit, plugin commands, andauthreject unsupported formats (e.g.-f xml) with a usage error (exit 2) instead of silently rendering a table.yml,markdown) and case (-f YAML) are accepted and normalized everywhere.plugin listnoteplugin listintentionally keeps its human-friendly grouped listing as itstablerendering — whenever the effective format istable(the default or an explicit-f table), and regardless of TTY. Use-f jsonor-f yamlfor machine-readable output. This is documented indocs/cli-reference.mdxandskills/webcmd-usage/SKILL.md.Hosted mode
Hosted
list,profile, andplugin searchnow validate and normalize-f/--formatthrough the sameparseOutputFormatpath as the local CLI, so unknown formats fail with a usage error and aliases/case are handled consistently there too.Breaking change
-f/--formatvalues other thantable,plain,json,yaml,md, orcsvnow fail with a usage error (exit code 2) instead of silently rendering a table. This applies to builtin commands and adapter commands (e.g.webcmd hackernews top -f xml), and now also to hostedlist,profile, andplugin search. The PR commit carries aBREAKING CHANGE:footer so release-please emits the changelog entry automatically.Docs
docs/cli-reference.mdxandskills/webcmd-usage/SKILL.mdupdated to reflect the shared format behavior, theplugin listtable rendering, rejection of unknown formats, aliases, andplugin list -f json→[].Testing
npm test: 5195 passed, 1 skipped (16 new tests).npm run buildOK;check:hosted-contractcontract bytes unchanged;check:typed-error-lint0 new;check:silent-column-drop0 new.