Skip to content
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

Add --dump-format json #992

Merged
merged 23 commits into from
Nov 17, 2021
Merged

Add --dump-format json #992

merged 23 commits into from
Nov 17, 2021

Conversation

casey
Copy link
Owner

@casey casey commented Oct 9, 2021

Closes #989.

To Do

  • Document
  • Use --format=json instead of --json subcommand
  • Mark as --unstable
  • Consider using a less weird format for expressions and recipe bodies

@casey
Copy link
Owner Author

casey commented Oct 10, 2021

@dionjwa Have a look at this PR, in particular the tests in tests/json.rs, which show the JSON output.

@casey casey marked this pull request as ready for review October 10, 2021 08:37
@casey
Copy link
Owner Author

casey commented Oct 10, 2021

The feature is unstable for now, which means that you have to use the --unstable flag. I did this because I'm a bit unsure of the exact details of the JSON format, and might want to change it based on feedback.

In particular, expressions are serialized in a lispy way which is easy to read, as opposed to the standard rust way. Also, recipes bodies are lists of lists containing either strings, or another list, containing an expression.

so:

foo:
  bar
  {{ baz }}

has:

...
"body":
  [
    // first line, contains recipe text
    ["bar"],
    // second line, contains an interpolation, represented as a list
    // the contents of the interpolation is an expression, in this case `["variable", "baz"]`,
    // which is the same representation of expressions used elsewhere
    [[["variable", "baz"]]],
  ]
...

@casey casey changed the title Start working on --json command Add --dump-format json Oct 14, 2021
@casey
Copy link
Owner Author

casey commented Oct 17, 2021

@dionjwa Ping! Let me know if this format is what you were looking for, if you get the chance.

@dionjwa
Copy link

dionjwa commented Nov 5, 2021

Feedback:

Maybe --dump automatically defaults to --dump=json, allowing future formats (unlikely, JSON is too ubiquitous, but?) if/when needed (--dump=yaml or --dump yaml).

As long as the recipe data contains the dependencies, I'm good. The fact that you're actually putting the recipe content there as expressions is just extra awesomeness. I don't need that part right now, but I can easily imagine wanting that in the future since it allows introspection.

Thank you so much!

@casey
Copy link
Owner Author

casey commented Nov 8, 2021

Maybe --dump automatically defaults to --dump=json, allowing future formats (unlikely, JSON is too ubiquitous, but?) if/when needed (--dump=yaml or --dump yaml).

--dump is already used to dump the text contents of a justfile, so making it default to --dump wouldn't be backwards compatible.

As long as the recipe data contains the dependencies, I'm good. The fact that you're actually putting the recipe content there as expressions is just extra awesomeness. I don't need that part right now, but I can easily imagine wanting that in the future since it allows introspection.

Sweet, good to know! What language and library will you use to deserialize the JSON?

Thank you so much!

You bet! This has been a long time coming, so I'm glad to have a user driving it forward.

@casey casey merged commit 0ae9188 into master Nov 17, 2021
@casey casey deleted the json branch November 17, 2021 08:07
@casey
Copy link
Owner Author

casey commented Nov 17, 2021

@dionjwa Merged! Let me know how it works for you. Also, if you need me to cut a release so you can experiment with it, let me know.

@dionjwa
Copy link

dionjwa commented Dec 1, 2021

That would be great, but also no rush 👍🏻

@casey
Copy link
Owner Author

casey commented Dec 1, 2021

@dionjwa I released 0.10.4, which includes --dump-format json. Hope it works for you!

@dionjwa
Copy link

dionjwa commented Dec 1, 2021

You're wonderful, thank you! I'll let you know when I finish this crazy esoteric use case I have in mind

@casey
Copy link
Owner Author

casey commented Dec 1, 2021

You bet! Looking forward to it :)

@clo4 clo4 mentioned this pull request Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Machine readable metadata from justfile?
2 participants