Conversation
The default table output of a single-object response listed only its top-level scalar fields. Arrays, nested objects and maps were skipped without any sign, so `member notify --dry-run` printed the email html but none of the per-recipient outcomes, and a detail response whose useful content is nested looked nearly empty. The key/value table now lists every non-empty scalar value reachable from the object, naming nested ones by their path (OWNER.EMAIL, LABELS.env, RECIPIENTS[0].STATUS). List pages keep their column tables. Table cells are also folded to one line. A multi-line value such as an email body used to spill onto following lines that read as extra rows; line breaks and indentation now collapse to single spaces, and long values are still truncated unless --no-trunc is set. A bare array of scalars (monit datasource-sls-logstores) no longer panics in table mode; it prints as JSON like other shapes a table cannot model.
A []byte or json.RawMessage field reached the key/value walk as a slice of uint8, so it would print one row per byte instead of its value. Byte slices are now single table cells, shown the way --json encodes them: a json.RawMessage as its compact JSON text, any other []byte as base64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a command returns a single object, the default table output listed only the object's top-level scalar fields. Arrays, nested objects and maps were skipped with no sign that anything was missing.
--jsonand--output-format toonwere not affected.For example,
member notify --dry-runprints{html, recipients: [...]}, but the table showed onlyhtml, and the multi-line email body spilled onto lines that looked like extra rows:Every command that renders through the shared generic renderer (
renderGenericTable) had the same gap. That covers all generated commands plus the curatedautomation,monit queryand Prometheus label-values commands. Any detail response whose content is nested lost that content in the table, such asPrometheusLabelValuesResponse.dataorKnowledgeGetResponse.files.Change
TablePrintercollapses line breaks and indentation inside a value to single spaces, so a multi-line value stays on its own row. Long values are still cut at the column width with...unless--no-truncis set. For a largehtmlbody the default view shows a readable one-line preview, and--no-truncor--jsonreturns the whole body.monit datasource-sls-logstorescrashed withreflect: NumField of non-struct type string. It now prints JSON, like other shapes a table cannot model.After:
Alternatives considered
Tests
TestRenderGenericTable_DetailShowsNestedFieldschecks the exact output for a nested object, an array of objects, an array of scalars, a map, ananyvalue and a nil pointer.TestMemberNotifyDryRunTableShowsRecipientsrunsmember notify --dry-runin the default table mode against the stub server. It checks every recipient outcome and that the multi-line body stays on one row.TestRenderGenericTable_TopLevelScalarArraychecks that a bare scalar array prints without a panic.TestTablePrinter_MultilineValueStaysOnItsRowchecks that a cell stays on one line with and without truncation.All four failed before the fix.
make test,make lint,make check-cardsandmake buildpass.