Skip to content

Add [metadata] attribute for adding custom metadata to recipes #2794

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

Merged
merged 4 commits into from
Jul 4, 2025

Conversation

wiktor-k
Copy link
Contributor

@wiktor-k wiktor-k commented Jun 26, 2025

This PR adds metadata attribute, which can appear multiple times on a recipe. The attribute takes a list of strings and its value can be inspected via JSON dump of the justfile.

The primary motivation is custom tooling built around just that can be used to, for example, automate creation of CI pipelines and other pre-processing that is outside of just's scope.

Fixes: #2703

@casey
Copy link
Owner

casey commented Jun 30, 2025

This mostly looks fine to me! However, I have some questions about the design:

  • What's the use-case for more than one metadata attribute?
  • Should we allow the metadata attribute to take a list of strings, instead of a single string? I think the main reason to do this is that it's more compact than multiple metadata attributes, since it's one line instead of multiple lines. We should think about this now, since it's a breaking change for JSON deserializers if metadata changes from a string to a list of strings.

@wiktor-k
Copy link
Contributor Author

wiktor-k commented Jul 1, 2025

This mostly looks fine to me! However, I have some questions about the design:
What's the use-case for more than one metadata attribute?

I wonder if you're asking about metadata being repeatable or a more generic question about attaching multiple metadata items per recipe. If it's the latter I envisioned multiple tools, each with their own metadata, which can at the same time use just so there needs to be some way to specify multiple items. The other approach would be to have the metadata attribute take multiple strings and expose that via JSON as a metadata array.

(As a practical example, I'm currently parsing pragma-like comments from recipes using JavaScript and there are multiple different ones in one recipe).

I initially chose "repeatable" as I had key-value structure for metadata in mind (where each external tool would use their different key and they could coexist) but stopped half-way as I was wondering if this is a bit too complex.

Should we allow the metadata attribute to take a list of strings, instead of a single string? I think the main reason to do this is that it's more compact than multiple metadata attributes, since it's one line instead of multiple lines.

I think it's a reasonable approach and I'm happy to adjust the code if we settle on this.

We should think about this now, since it's a breaking change for JSON deserializers if metadata changes from a string to a list of strings.

Totally agreed. The PR didn't take too much time and I think having something concrete is a great conversation starter.

Thanks for your time! 👋

@casey
Copy link
Owner

casey commented Jul 4, 2025

Let's allow a list of strings, as well as allowing the metadata attribute to appear multiple times. I don't see any issue with it, and it allows metadata authors flexibility in how they'd like to structure their metadata.

@wiktor-k wiktor-k force-pushed the wiktor-k/2703-add-metadata branch from 5ebdf8d to a3352bf Compare July 4, 2025 09:44
This PR adds `metadata` attribute, which can appear multiple times on a recipe.
The attribute takes a list of strings and its value can be inspected via
JSON dump of the `justfile`.

The primary motivation is custom tooling built around `just` that can be
used to, for example, automate creation of CI pipelines and other
pre-processing that is outside of `just`'s scope.

Fixes: casey#2703
@wiktor-k wiktor-k force-pushed the wiktor-k/2703-add-metadata branch from a3352bf to ba89d5c Compare July 4, 2025 09:51
@wiktor-k
Copy link
Contributor Author

wiktor-k commented Jul 4, 2025

I don't see any issue with it, and it allows metadata authors flexibility in how they'd like to structure their metadata.

Good idea.

I've left the constraint to require at least one argument in the [metadata] attribute as it seemed weird to have an argumentless node like that.

The code could be restructured a bit because structure-wise what [metadata] takes looks identical to the Interpreter struct (one required "command" and a set of arguments). I've kept the code simple for now, unless you see value in adjustments.

@wiktor-k wiktor-k changed the title Add metadata attribute for adding custom metadata to recipes Add [metadata] attribute for adding custom metadata to recipes Jul 4, 2025
@casey casey enabled auto-merge (squash) July 4, 2025 21:47
@casey casey disabled auto-merge July 4, 2025 21:47
@casey casey enabled auto-merge (squash) July 4, 2025 21:51
@casey casey disabled auto-merge July 4, 2025 21:53
@casey casey enabled auto-merge (squash) July 4, 2025 21:53
@casey
Copy link
Owner

casey commented Jul 4, 2025

LGTM!

@casey casey merged commit bfa5a6d into casey:master Jul 4, 2025
6 checks passed
@wiktor-k wiktor-k deleted the wiktor-k/2703-add-metadata branch July 5, 2025 06:09
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.

Custom attributes / metadata attributes
2 participants