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 extensible recipe and justfile annotations #604

Closed
casey opened this issue Mar 9, 2020 · 10 comments
Closed

Add extensible recipe and justfile annotations #604

casey opened this issue Mar 9, 2020 · 10 comments

Comments

@casey
Copy link
Owner

casey commented Mar 9, 2020

I think that Just would benefit from syntax for annotations / attributes.

This might be used for:

I've been thinking about rust-style (#[foo]) or C# style ([foo]), and I think rust style would be better, since it won't conflict with array notation ([...]), and there's a precedent for attributes that apply to the containing item (#![foo]).

So recipe attributes would look like:

#[quiet]
foo:
  echo foo

and module attributes would look like:

#![feature(modules)]

# rest of justfile

An initial PR need only support recipe or module attributes, not both, and could initially only support a single ident as the attribute contents.

@plus7wist
Copy link

Good idea :3

@plus7wist
Copy link

I like the Rust style, because just is written in Rust. Rust guys will be happy.

@runeimp
Copy link

runeimp commented Mar 18, 2020

I think both styles are fine. The C# user base is, I believe, significantly larger than the Rust user base. So the syntax would be more familiar to more people. On the other hand The C# style makes me thing INI file and annotations should not be confused with section headers. The Rust style actually looks more like an annotation to me too.

@casey
Copy link
Owner Author

casey commented Mar 19, 2020

Just to make an arbitrary decision, let's go with Rust-style. I personally think that C# is nicer looking, but I do like that Rust-style makes it clear that they're annotations.

@casey casey changed the title Add extensible recipe annotations Add extensible recipe annotations/attributes Mar 19, 2020
@rjsberry
Copy link
Contributor

rjsberry commented Jun 3, 2020

I would contend that the C# style is a better choice.

Everywhere else we have # to start comments. I think that the lack of the hash creates strong visual separation between the comment for the recipe and the recipe itself.

When using make syntax for highlighting on GitHub/similar, it also means that the attributes will not be highlighted as comments.

Consider:

# this is an example
#[foo]
#[bar]
baz:
  echo baz

The attributes are obviously highlighted wrong. But also they are not clearly attributes at a glance because of the leading #.

Compare this to:

# this is an example
[foo]
[bar]
baz:
  echo baz

I personally find this much clearer. Visually speaking the lines containing attributes are cleanly separated from the comment as the first character of the line is [.

@casey
Copy link
Owner Author

casey commented Jun 26, 2020

I do think that C# attributes are more attractive, and the syntax highlighting argument is persuasive. C# uses curly braces for arrays (e.g. {1,2,3,4}), so there's no ambiguity there. Using […] for annotations would mean that we couldn't use […] for arrays in Just, which doesn't seem ideal.

@casey casey removed this from the eventually milestone Jul 2, 2020
@casey casey changed the title Add extensible recipe annotations/attributes Add extensible recipe and justfile attributes Jul 20, 2020
@casey casey pinned this issue Feb 19, 2022
@casey casey changed the title Add extensible recipe and justfile attributes Add extensible recipe and justfile annotations Feb 19, 2022
@casey casey unpinned this issue Jul 24, 2022
@casey
Copy link
Owner Author

casey commented Oct 25, 2022

We have our first annotation, [no-exit-message], implemented in #1354, so I guess we're going with C#-style annotations, which is nice, since they won't be hidden as comments.

@casey casey closed this as completed Oct 25, 2022
@casey
Copy link
Owner Author

casey commented Oct 25, 2022

And we can still use […] for arrays, since annotations and arrays are unlikely to be in the same positions in the grammar.

@mkatychev
Copy link

mkatychev commented Feb 8, 2024

@casey are there any discussions on doing cargo style [not(condition)]/[condition] annotations?:

[not(windows)]
run:
  cc main.c
  ./a.out
  
[windows]
run:
  cl main.c
  main.exe

I imagine my usecase is quite common for some when dealing with doing/avoiding setup specific to CI environments:

[env_var("CI") == "true"]
run:
  ./do_the_ci_setup.sh
  ./run.sh

[not(env_var("CI") == "true")]
run:
  ./run.sh

@casey
Copy link
Owner Author

casey commented Feb 11, 2024

I opened #1895 to track inverted cfg style attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants