-
Notifications
You must be signed in to change notification settings - Fork 47
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
Extract export package from gh #67
Conversation
pkg/template/template.go
Outdated
} | ||
} | ||
|
||
func (t *Template) Parse(tpl string) 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.
This is the only change from the cli
version of this package. Parse
now needs to be explicitly called rather than implicitly being called from within Execute
. I made this change to reduce the number of arguments to New
and Execute
. Additionally, I find the explicitness of it to be easier to follow.
) | ||
|
||
// Evaluate a jq expression against an input and write it to an output. | ||
func Evaluate(input io.Reader, output io.Writer, expr string) 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.
Open to naming suggestions here? I also changed the argument order to have the input
come first compared to the same function in gh
.
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.
naming makes sense to me
return t.tmpl.Execute(t.output, data) | ||
} | ||
|
||
func (t *Template) Flush() 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.
This used to be called End
but I felt Flush
was a more clear representation of what it does.
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.
looks great, thanks for being clear about what changed.
) | ||
|
||
// Evaluate a jq expression against an input and write it to an output. | ||
func Evaluate(input io.Reader, output io.Writer, expr string) 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.
naming makes sense to me
This PR extracts out the
export
package fromgh
. Functionality wise, there are minimal changes compared to the counterpart packages ingh
. After this is merged I will make a follow up PR in cli/cli to use this extracted package.cc cli/cli#5544