feat: add task name to the json output #2256
Merged
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.
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