Enable displaying tasks as JSON#165
Open
ryanprior wants to merge 3 commits into
Open
Conversation
17e6d50 to
c949995
Compare
Uses encoding/json package to write a task to the target writer as JSON. Co-authored-by: jgart <jgart@dismail.de>
Co-authored-by: jgart <jgart@dismail.de>
c949995 to
874bdfd
Compare
Contributor
Author
|
Interesting wrinkle: the error case for the JSON display function wasn't covered in testing, which caused test coverage overall to drop and held up the PR. I dug into the JSON docs in golang to find a value that would trigger the error case so I could account for that in testing, and found that none of the types in the Task struct can accept un-marshalable values. (I tried typecasting and that just resulted in weird, but valid, values.) So I removed the error handling code and left a comment in its place 🙃 Here's the code coverage report that helped me understand that was what was causing code coverage to drop: https://coveralls.io/builds/77696075/source?filename=models%2Fmodels.go#L63 |
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.
Fixes #149
Context
In my Emacs integration for xc, I would like to prompt the user for task inputs when they're required, but it's not as straightforward to enumerate the task inputs as I'd like. This PR adds a facility to display the JSON representation for the parsed task data structure, which is ideal for tool integrations like this.
In this PR
Task.DisplayJSONinmodelspackage-output, defaulting to "markdown" but also accepting "json", for the user to control how to display a task (with-display)Next steps
Now that this is ready for review, I'll start work to use this data in the Emacs integration to enumerate task inputs and prompt for them interactively.
Special thanks
Appreciation to @jgarte for pair programming with me on this enhancement. Thank you Jorge!