-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: output flag config cmd #202
feat: output flag config cmd #202
Conversation
cmd/environments/get.go
Outdated
@@ -68,7 +68,7 @@ func runGet( | |||
|
|||
output, err := output.CmdOutput( | |||
viper.GetString(cliflags.OutputFlag), | |||
output.NewSingularOutputterFn(response), | |||
output.NewSingularOutput(response), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed these functions to be simpler to read.
internal/output/config_outputter.go
Outdated
} | ||
|
||
// New unmarshals a single config resource and wires up a particular plain text output function. | ||
func (o configOutputterFn) New() (Outputter, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
internal/output/config_outputter.go
Outdated
return SingularOutputter{}, err | ||
} | ||
|
||
return SingularOutputter{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to reuse this type since it's a singular resource but a different way to format.
internal/output/output.go
Outdated
@@ -23,14 +23,12 @@ type OutputterFn interface { | |||
} | |||
|
|||
// PlaintextOutputFn represents the various ways to output a resource or resources. | |||
type PlaintextOutputFn func(resource) string | |||
type PlaintextOutputFn[T any] func(t T) string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now this can take different resource types.
* 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
Supports plain text and JSON output for the
config --list
command.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.