-
Notifications
You must be signed in to change notification settings - Fork 343
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
Bikeshedding how we use/offer templates #3262
Comments
My thoughts, in no particular order, and assuming no particular prior knowledge of the reader:
|
Summarizing my thougths on the templating system:
|
From #3219: I'd love to see some common encoding functions built into the templating language to facilitate integrations with editors, shell prompts, and really anything that would prefer to parse structured data, rather than human-readable plain text. Something like: jj log --template 'json({ id: commit_id, author: author, desc: description })'
jj log --template 'csv([ commit_id, author, description ])'
jj log --template 'toml(commit_id)' This also means that Jujutsu doesn't need to commit to a JSON output interface beforehand and each integration gets to pick its preferred output with exactly the data it wants. I'm not sure if Jujustu currently has support for list literals or "object/map" literals, so this proposal might mean an expansion in expressiveness to the language. |
Composing object literals shouldn't be a problem. In the case of structuring output, what I suggested would mean |
Implementation-wise, jj's templater is a typed language right now (and has method name resolution based on type), so introducing first-class user object literal or heterogeneous list will add complexity. I'm not against adding some sort of dynamic types, but I generally like the strictness of jj's template error handling. JSON specially has another problem that template outputs can't be simply streamed. Mercurial has a nasty hack to omit the last "," iirc. |
I didn't mean to suggest heterogeneous lists, I'm actually not a fan of those in general. I mispoke in my last, "s/return/take/ a nested map".
We shouldn't need to worry about that, we can just invoke |
It works only for one serializable object, right? If we don't need to support arbitrary template queries, using static |
Why? Json streams are a format λ echo '{}{}{}' | jq
{}
{}
{}
λ echo '{}{}{}' | jq --slurp
[
{},
{},
{}
] Yes I was thinking it would be super-easy to just dump template objects through serde_json and call it a day 🤷 |
Yeah, it's easy if the caller expects json streams. I just mean a pure json array can't be constructed that way (and Mercurial has a workaround for that.) |
FWIW, I'm not a huge fan of adding additional functionality to the templating language for this kind of thing. IMO, templates should be used by humans, and not by computers, so I don't like the idea of attempting to support json in them. If you're using a template for use by a computer, IMO |
Then how do you solve the bootstrapping problem, while nothing of sorts exists yet? The template language is available and we've had repeated requests to support some kind of dynamic configuration with it. And 3rd parties want to integrate w/o using the library directly. I agree that in the future |
I agree that this will make the pain lesser until it exists, but I have a few concerns about doing so
This is a slightly awkward currently, but it is possible, and not particularly difficult. I've already done so myself (I wrote a python script that allows you to run
I then run:
IMO, the actual implementation of |
Templating (like scripting) is quite a deep topic, and how it's relevant to this project has had a fair amount of conversation to date, and will likely continue to need more for a while to go. This issue is meant to serve as a place to aggregate and hash out desires, concerns, and anything else that might inform the total story of templating in Jujutsu.
A gentle reminder that push back does not mean that desires/needs are invalid, we're all here to try and make Jujutsu as good of a tool as it can be.
It would be appreciated if collaborators could help keep the below sections updated
Stance summaries
Comments of note
The text was updated successfully, but these errors were encountered: