feat: output flag config cmd#202
Merged
dbolson merged 6 commits intoApr 24, 2024
Merged
Conversation
dbolson
commented
Apr 23, 2024
| output, err := output.CmdOutput( | ||
| viper.GetString(cliflags.OutputFlag), | ||
| output.NewSingularOutputterFn(response), | ||
| output.NewSingularOutput(response), |
Contributor
Author
There was a problem hiding this comment.
Renamed these functions to be simpler to read.
| } | ||
|
|
||
| // New unmarshals a single config resource and wires up a particular plain text output function. | ||
| func (o configOutputterFn) New() (Outputter, error) { |
Contributor
Author
There was a problem hiding this comment.
By making the output API simpler for the caller, we're forced to implement a new New() method in addition to a new PlaintextOutputFn type. If we find the tradeoff not worth it, we can reconsider.
| return SingularOutputter{}, err | ||
| } | ||
|
|
||
| return SingularOutputter{ |
Contributor
Author
There was a problem hiding this comment.
I was able to reuse this type since it's a singular resource but a different way to format.
|
|
||
| // PlaintextOutputFn represents the various ways to output a resource or resources. | ||
| type PlaintextOutputFn func(resource) string | ||
| type PlaintextOutputFn[T any] func(t T) string |
Contributor
Author
There was a problem hiding this comment.
Now this can take different resource types.
sunnyguduru
approved these changes
Apr 24, 2024
* Add plain text error handling * Output flag errors as plain text or JSON * Remove unused code * Update all commands to return plaintext or JSON * Refactor outputter * Backfill tests * Reorganize * Refactor * Remove comments * Renamed functions
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.
Supports plain text and JSON output for the
config --listcommand.Requirements
Related issues
Provide links to any issues in this repository or elsewhere relating to this pull request.
Describe the solution you've provided
Provide a clear and concise description of what you expect to happen.
Describe alternatives you've considered
Provide a clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the pull request here.