Consolidate CLI formatting infrastructure#1385
Open
realrajaryan wants to merge 2 commits intoapple:mainfrom
Open
Consolidate CLI formatting infrastructure#1385realrajaryan wants to merge 2 commits intoapple:mainfrom
realrajaryan wants to merge 2 commits intoapple:mainfrom
Conversation
jglogan
reviewed
Apr 3, 2026
| import Foundation | ||
|
|
||
| public struct TableOutput { | ||
| struct TableOutput { |
Contributor
There was a problem hiding this comment.
One consideration here: what public visibility is needed for commands in third-party libraries/plugins that depend on ContainerCommands and want to produce consistent collection output?
Contributor
Author
There was a problem hiding this comment.
Yeah. I don't mind, we can make it public for third party use cases
jglogan
reviewed
Apr 3, 2026
| .forEach { print($0.id) } | ||
| return | ||
| } | ||
| private struct PrintableBuilder: ListDisplayable { |
Contributor
There was a problem hiding this comment.
Is there a reason we can't define a ListDisplayable extension on the bulk of or regular types instead of defining completely separate types that conform to that protocol? It feels like there might be a bit more boilerplate as it currently stands.
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.
Motivation and Context
This PR consolidates duplicated list-output formatting across the CLI into shared rendering infrastructure.
Currently, each list command has its own copy of the same json/quiet/table branching. This PR pulls that into shared rendering infrastructure in
ContainerCommands:ListDisplayableprotocol for table + quiet outputrenderJSON,renderTable,renderListas pure functions that return stringsemit()as the single stdout boundary (no-ops on empty strings to avoid blank-line regressions)JSONOptionsso all JSON encoding goes through one path, including volume inspect's pretty + ISO 8601 caseJSON encoding remains separate from display formatting: each command still chooses its own JSON model, while
ListDisplayableis used only for table and quiet output.ImageListremains the intentional exception for quiet mode so it can avoid unnecessary async work.This change also replaces inline
JSONEncoderusage withrenderJSON, removes the oldCodable+JSON.swifthelper, and movesTableOutputandListFormatintoContainerCommands. It also adds unit tests for the shared rendering helpers and expands integration coverage for image, network, and registry list formatting.Testing