Repository navigation
feat(cli/cliui): add TextFormatFunc and OutputFormatter.WriteLine helpers - #30508
Merged
nickvigilante merged 2 commits intoOct 8, 2026
Conversation
Commands adding -o/--output repeat the same type-assertion wrapper around ChangeFormatterData(TextFormat(), ...) and the same format-then-Fprintln block. These helpers let each command express only its rendering logic. Refs CLI-56
jeremyruppel
reviewed
Oct 8, 2026
jeremyruppel
left a comment
Collaborator
There was a problem hiding this comment.
A few non-blocking notes.
Note
This review was generated by Coder Agents on behalf of @jeremyruppel.
… names WriteLine makes the trailing newline visible at call sites and avoids confusion with io.Writer. TextFormatFunc now names the expected type with reflect.TypeFor, since %T on a nil interface value prints <nil>.
jeremyruppel
approved these changes
Oct 8, 2026
jeremyruppel
left a comment
Collaborator
There was a problem hiding this comment.
this rules. thanks for extracting this into a helper, I think we'll get some mileage out of it 🚗
nickvigilante
enabled auto-merge (squash)
October 8, 2026 18:41
nickvigilante
deleted the
vigilante/cli-56-cliui-add-shared-text-formatter-and-write-helpers-for-o
branch
October 8, 2026 19:41
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Adds two small helpers to
cli/cliui/output.goso commands that add-o/--outputdon't repeat the same boilerplate, as suggested in #30152 (comment) by @jeremyruppel.TextFormatFunc[T]wrapsChangeFormatterData(TextFormat(), ...)with the type assertion and "expected X, got Y" error, so a command only supplies its render function.(*OutputFormatter).WriteLineformats data and writes it to anio.Writerwith a trailing newline, replacing theFormat+Fprintlnblock.No existing callers change in this PR. These PRs are stacked on it and use the helpers:
coder tokens createcoder ai-gateway keys createcoder organizations members edit-rolescoder provisioner keys createMigrating the existing callers on
main(for examplecli/organization.go,enterprise/cli/workspaceproxy.go) is left for a follow-up, since some of them print withFprintrather thanFprintlnand need care to keep output identical.Refs CLI-56
Decision log
-oflag on the root command was ruled out becausecoder config-sshalready uses-ofor--ssh-option.WriteLineusesFprintlnto match the four stacked PRs and most existing callers.It was renamed from
Writeduring review so the trailing newline is visible at call sites and the method is not confused withio.Writer.Note
This PR was generated by Coder Agents on behalf of @nickvigilante.