-
-
Notifications
You must be signed in to change notification settings - Fork 687
feat: add task name to the json output #2256
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: add task name to the json output #2256
Conversation
bd4065f
to
c58d59d
Compare
task_test.go
Outdated
// WithFixtureTemplateData sets up data defined in the golden file using golang | ||
// template. Useful if the golden file can change depending on the test. | ||
// Example template: {{ .Value }} | ||
// Example data definition: struct{ Value string }{Value: "value"} | ||
func WithFixtureTemplateData(data interface{}) TestOption { | ||
return &fixtureTemplateDataTestOption{data: data} | ||
} | ||
|
||
type fixtureTemplateDataTestOption struct { | ||
data interface{} | ||
} | ||
|
||
func (opt *fixtureTemplateDataTestOption) applyToExecutorTest(t *ExecutorTest) { | ||
t.fixtureTemplateData = opt.data | ||
} | ||
|
||
func (opt *fixtureTemplateDataTestOption) applyToFormatterTest(t *FormatterTest) { | ||
t.fixtureTemplateData = opt.data | ||
} | ||
|
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.
Niceee! I really like this idea. In other tests we use a post-process function to remove absolute paths from the fixtures, but I was never really happy with that solution. This is much cleaner!
I wonder if we should provide a standardised set of variables to all tests for this purpose. No need to do this in this PR though.
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.
Thank you, Pete! I'm glad you found these changes interesting
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.
LGTM once the linting checks pass
c58d59d
to
e1b6f4b
Compare
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.
🚀 LGTM. Pending a second review
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.
Like @pd93, I like your solution regarding the test !
LGTM
Hi, nice to meet you, and thanks for developing the task tool!
Rationale
I'm implementing the tui client for the task. I have decided that the best way to integrate a user interface is to use the JSON output feature (
task --list --json
).All works fine except the labels. If some tasks have the label field, the JSON output will contain it instead of the real name. Since I can't request the execution by the task label, the client is stuck here.
task/taskfile/ast/task.go
Line 53 in da4ce5b
I found the same problem in the vscode plugin (go-task/vscode-task#167) since it is integrated with the task in the same way.
Changes
I assume that it's not right to change the behavior of this field, because there are some tools which can rely on this. Therefore, I decided to add a separate field (
task
) with the real task name, which can be used exactly for the purpose of executing the task.The new JSON output will look like below