-
Notifications
You must be signed in to change notification settings - Fork 510
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 support for [alias(name)]
attribute
#2344
Conversation
5f2b9eb
to
2b8912b
Compare
Why? |
I prefer the attribute syntax to assign metadata to a recipe over the Why not? |
I think I'm also a bit skeptical. I don't see a huge benefit in being able to declare aliases multiple ways, and since aliases are very user-facing, I think the dedicated item syntax makes them more discoverable. |
Doesn't being able to There certainly isn't a huge benefit to this addition, I just thought it'd be a nice way to be able to set aliases. Or at least it's the way I'd prefer to be able to 😅 |
Personal preference of someone other than @casey is not a rationale for a
This new way to create aliases doesn't add additional functionality, while it does add (some) maintenance burden. To maximize the space for And alias doesn't even make sense as an attribute. Attributes change recipe behavior. Aliases only provide alternative ways to invoke recipes from the command line, the recipe has the same behavior as if invoked by its real name.
Nope, justfile authors aren't going to intentionally disorganize their justfiles for the purpose of making it harder for them to manage their own justfiles. And for people who run justfiles, this is moot since they'll just look in |
@laniakea64 sorry, this was rude. I interpreted your "Why?" as being rude here, but I should not have. I'm realizing I really didn't provide enough context in the original request. Let me try again. I think it would be nice to have the ability to set aliases for a recipe with an attribute. I find that it keeps the information about a recipe more condensed and visually parseable when reviewing a recipe. I find it cleaner than setting an alias elsewhere in the file using the keyword. |
I see. For some reason I thought a recipe could use aliases as dependencies, and that's what the
These are absolutely good points, and I may have gotten a bit ahead of myself here. Probably should have started with an issue to get feedback first. |
For what it's worth, I think that having a syntax to define an alias immediately next to the recipe it's an alias for is convenient. If the It's also the case that there's a few places in
Some uses of attributes are better characterized as adding metadata to a recipe than changing its behavior -
Something that I've noticed when working with large, multi-module |
It already exists. The existing
(bolding mine) If the
... and the time to add
Wouldn't a justfile linting tool be a more effective way to address that? |
Also along these lines, taking an identifier as an attribute argument will break ever being able to use a |
My first attempt at this was extending My second attempt I switched to using However, doesn't this help to pave the way to work with some of those cases you've stated above? By wrapping attribute arguments in This implementation isn't necessary the best one, but ideally I'd like to find the correct one through discussion. |
The given example justfile syntax was -
Once this is valid syntax, b := 'variableB'
[alias(b)] # since this worked as a literal b before, it must always be a literal b, it cannot change to variableB
bar:
echo "bar" Whereas string literal wouldn't close that option: b := 'variableB'
[alias("b")] # this would stay a literal b even if variables/expressions become allowed here, and does not interfere with later ability to use the variable b in this position
bar:
echo "bar"
Sounds like these internal changes could help implement #2287 (comment) / #1955 (comment) 👍 If casey agrees that's the way to do it, that part would probably be best as a separate PR tagging those issues and not adding new attributes. Up to casey. |
EDIT: I may have misunderstood. You’re saying the current output would be problematic because you couldn’t do EDIT2: However, this is how aliases currently behave. An alias name is a |
2de88a2
to
6ef4f36
Compare
I think the ideal behavior would be that the I can definitely see the merits of the arguments here, pro and con. I'm slightly leaning towards not adding a new attribute, but if other people want it, then I could see adding it. I think for now I'm leaning towards closing this PR, but I opened #2349 so the feature can be discussed. |
This adds an
[alias(name)]
attribute to Just, allowing aliases to be set in two ways.The
alias
attribute will inherit theprivate
attribute from it's associated/target recipe.This will need some additional tests and documentation of course, but figured I'd submit it first to make sure it's a desirable feature/implemented alright.