fix: human output honors default_fields; --schema reports when none registered#23
fix: human output honors default_fields; --schema reports when none registered#23jpage-godaddy wants to merge 5 commits into
Conversation
…registered Human (table) output previously ignored a command's default_fields and dumped every column. It now applies default_fields in every format — json, toon, and human — so an interactive table shows the curated columns. The one exception is a command with a registered HumanView: that view selects its own columns from the full payload, so projecting first would strip fields it needs. Full data is always one flag away via `--fields all` / `--output json`. `--schema` previously fell through and ran the command when no output schema was registered, which was confusing. It now returns a clear message pointing at `--fields all` instead of executing the command. Adds HumanViewRegistry::has_view and tests for both behaviors. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves output discoverability and consistency in the CLI engine by (1) making human/table output honor a command’s default_fields (matching existing behavior in JSON output) and (2) making --schema reliably short-circuit with a clear message when no schema is registered, instead of silently running the command.
Changes:
- Apply
default_fieldsfield projection to Human output, except when a registeredHumanViewexists for the command’s schema/system (to avoid stripping fields the view needs). - Make
--schemaalways short-circuit; when no schema is registered, return a JSON envelope containing a clear “no schema registered” message and a hint to use--fields all/--output json. - Add/adjust tests to cover human projection behavior (including the registered-view exception) and the new
--schemano-schema message path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/middleware.rs |
Implements schema short-circuit messaging and updates field selection logic to apply default_fields in Human output except when a HumanView is registered. |
src/output/human.rs |
Adds HumanViewRegistry::has_view to allow middleware to detect registered views and avoid pre-projection. |
tests/foundation.rs |
Adds coverage for --schema with no schema registered and fixes a registered-view test to register under the resolved system id. |
tests/consumer_cli.rs |
Adds integration-style tests verifying Human output respects default_fields, and that --fields all overrides it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…essage The second sentence suggested "run it with --fields all", but --schema is meant NOT to run the command — and that advice would execute a mutation. Keep the message to the accurate first sentence. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Return `{command, fields: []}` (plus an additive `message`) so consumers can
parse the registered and unregistered cases uniformly, instead of the previous
`{command, schema: null, message}`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
A bit out of my depth on the specific changes here, still need to learn more about the internals of cli-engine to properly review. Two edge case issues flagged by my agents, I think they're reasonable concerns but take with a grain of salt:
Suggested Tests |
What & why
Two output-discoverability fixes that surfaced while building a consumer CLI.
1. Human output honors
default_fieldsPreviously the human (table) renderer ignored a command's
default_fieldsand dumped every column, whilejson/toonhonored it. A command with a curateddefault_fields(e.g.domain,status,expires) still produced a 15+ column wall in an interactive terminal.Now
default_fieldsapplies in every output format. The one exception: a command with a registeredHumanView— that view selects its own columns from the full payload, so pre-projecting would strip fields it needs. Those commands are unchanged.Full data is always one flag away:
--fields all/--fields '*'/--output json.2.
--schemareports when no schema is registeredPreviously
--schemaon a command with no registered output schema silently fell through and ran the command — surprising and easy to mistake for a broken flag. It now returns a clear message instead of executing the command:(The message intentionally does not suggest "run it with
--fields all":--schemamust not execute the command — that would run a mutation.)Changes
src/middleware.rs— applydefault_fieldsin human mode unless aHumanViewis registered for the command's system; emit a no-schema message instead of falling through.src/output/human.rs— addHumanViewRegistry::has_view.tests/— cover human projection (with the registered-view exception) and the no-schema--schemamessage. Also corrected an existing registered-views test that registered its view under a non-matchingschema_id, so it now actually exercises the view path.Verification
cargo fmt --check,cargo clippy --all-targets -- -D warnings, andcargo testall clean.🤖 Generated with Claude Code