Implement tabular and property-based CLI output formatting#11
Merged
Conversation
hacktobeer
approved these changes
Apr 2, 2026
|
|
||
| // Custom label mapping for a cleaner UI | ||
| switch field.Name { | ||
| case "ID": |
There was a problem hiding this comment.
Make this a lookup table defined at the top instead of a case switch in a later PR. Cleaner.
Contributor
Author
There was a problem hiding this comment.
Good idea, I will add it.
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.
Summary
Refactored struct printing logic to support tabular views for collections and formatted property views for individual objects.
Technical Details:
FprintPropertyViewto display struct fields as vertical key-value pairs. This function maps Go field names to human-readable labels (e.g.,HashMD5toMD5) and filters out empty strings, nil pointers, and nested structures to reduce noise in the CLI output.FprintTableto render slices of structs as formatted tables. It dynamically selects columns based on field availability, prioritizing identifiers and metadata likeID,DisplayName,Size, andStatus.FormatTimeAgoto converttime.Timevalues into human-readable relative strings, such as "about 2 hours ago," for better temporal context in command outputs.FprintStructto act as a router, delegating toFprintTablefor slices andFprintPropertyViewfor single items, replacing the previous hyphen-separated list format.format_test.gowith test cases for table rendering, relative time calculations, and the updated property view logic.