fix(cli): resolve CLI-014..016 — re-triage update-command contract, doc-surface drift, table-column union
This commit is contained in:
@@ -181,9 +181,25 @@ internal static class CommandHelpers
|
||||
return;
|
||||
}
|
||||
|
||||
var headers = items[0].ValueKind == JsonValueKind.Object
|
||||
? items[0].EnumerateObject().Select(p => p.Name).ToArray()
|
||||
: new[] { "Value" };
|
||||
// Derive the header set as the union of property names across *every*
|
||||
// element, in first-seen order. Using only items[0] would silently drop
|
||||
// columns for any later element with a different shape (CLI-016).
|
||||
var objectItems = items.Where(i => i.ValueKind == JsonValueKind.Object).ToList();
|
||||
string[] headers;
|
||||
if (objectItems.Count > 0)
|
||||
{
|
||||
var seen = new List<string>();
|
||||
var known = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (var item in objectItems)
|
||||
foreach (var prop in item.EnumerateObject())
|
||||
if (known.Add(prop.Name))
|
||||
seen.Add(prop.Name);
|
||||
headers = seen.ToArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
headers = new[] { "Value" };
|
||||
}
|
||||
|
||||
var rows = items.Select(item =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user