Skip to content

A cloud resource printer - #17

Merged
anekkanti merged 7 commits into
mainfrom
abhinav/printerForCloudResources
Feb 20, 2026
Merged

A cloud resource printer#17
anekkanti merged 7 commits into
mainfrom
abhinav/printerForCloudResources

Conversation

@anekkanti

@anekkanti anekkanti commented Feb 19, 2026

Copy link
Copy Markdown
Member

Note

Medium Risk
Touches core CLI output formatting and reflection-based printing paths, so regressions could affect many commands’ human-readable output (though JSON output remains largely passthrough and changes are well-covered by tests).

Overview
Introduces a new resource-aware printer API: PrintResource renders structs as metadata + indented Spec, and PrintResourceList renders list responses as stable tables (with optional NextPageToken output) while preserving existing JSON behavior.

Enhances text rendering via pluggable converters (including built-in enum-to-string mapping for ResourceState and AsyncOperation state registered at CLI startup), improves nil/zero-value handling in table/card printing, and changes PrintDiff to emit structured JSON {before, after} when in JSON mode.

Updates namespace get, list, and lifecycle get commands to use the new resource printing functions and to show selected fields/spec fields for list output; expands printer tests substantially to cover these new behaviors and edge cases.

Written by Cursor Bugbot for commit 778f5c9. This will update automatically on new commits. Configure here.

@anekkanti
anekkanti requested a review from a team as a code owner February 19, 2026 02:23
Comment thread temporalcloudcli/internal/printer/printer.go
Comment thread temporalcloudcli/commands.go Outdated

@khisakuni khisakuni left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments regarding the cursor comments but otherwise lgtm!

Comment thread temporalcloudcli/internal/printer/printer.go

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Comment thread temporalcloudcli/internal/printer/printer.go Outdated
_, row := p.parseFields(resourceVal, options.Fields, []string{"Spec"}, 1)
_, specRow := p.parseFields(resourceVal.FieldByName("Spec"), options.SpecFields, nil, 1)
maps.Copy(row, specRow)
rows = append(rows, row)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nil pointer slice element causes panic in PrintResourceList

Low Severity

In PrintResourceList, when a slice element is a nil pointer, resourceVal.Elem() produces a zero reflect.Value. While parseFields safely handles this (line 760 checks IsValid()), the subsequent call to resourceVal.FieldByName("Spec") on the zero value panics. The analogous code in colFieldReader (lines 563-566) correctly checks v.IsNil() before calling Elem(), but PrintResourceList lacks this guard.

Fix in Cursor Fix in Web

}
if isZero(v.Field(i).Interface()) {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero-value fields unconditionally hidden by PrintResource

High Severity

parseFields unconditionally skips all zero-value fields via isZero, but the old PrintStructured path only omits zero-value fields when cardOmitEmpty is explicitly set via struct tag. This causes PrintResource to silently drop meaningful false/zero values. Most notably, EnableDeleteProtection: false in the lifecycle get command is completely omitted from text output, making it impossible for users to confirm that delete protection is disabled.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO print resource needs to be more human friendly, and with out this check it will print a lot of noise thats not idea. But i do get understand the risk of not printing zero values. Lets keep things as is for now and revisit this later.

@anekkanti
anekkanti changed the base branch from develop to main February 19, 2026 19:43
@anekkanti
anekkanti merged commit 0450152 into main Feb 20, 2026
6 checks passed
@anekkanti
anekkanti deleted the abhinav/printerForCloudResources branch February 20, 2026 18:54
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.

2 participants