-
-
Notifications
You must be signed in to change notification settings - Fork 635
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
Taskfile Scoped Variables #1030
Comments
I agree that variables scoped by Taskfile should be the default. Although we could add an option to explicitly allow variable sharing on particular includes, it's not ideal as the included task might still want to have a subset of its variables remain private. It's better for the included Taskfile to decide what's public and what's private. This could be achieved by introducing new I've noticed a lot of issues raised regarding the behaviour of variables and Taskfile inclusion. Examples are #454, #696, #778 and #996. It would be good to find a solution that addresses all of these issues. There seems to be two reasons that people use includes:
I wonder whether it makes sense to decouple these and come up with a separate mechanism for sharing variables across Taskfiles. As an alternative to the public/private idea, we could support a new file type (e.g. If we make variables in Taskfiles always private, then |
Yes it seems by default it should be private, and you have to explicitly expose or access the variables. Could we address this by somehow accessing the variables by namespace? Similar to how tasks are accessed? |
That's an interesting idea. It might be okay to do this for normal variables, but it may not be appropriate for environment variables. Environment variables are often processed by external programs, which will not handle there being a prefix on the environment variable name. |
@aliculPix4D FYI (would address #696). |
This would be great to have. I kinda understand the initial design of the taskfile - being composable and used like a mixin to inject variables; but on the other hand it makes more sense to have isolation and be able to build "self-contained" sub-taskfiles that one can copy and paste into other projects and just include them in the main taskfile. Since one can already import variables from another taskfile, i don't see a huge reason to not have such isolation. |
I also agree that the current behavior is confusing and non intuitive. My use case:
Including I think that the includes should be more modular and self enclosed - including a module should not have an effect on the outer world, unless you specifically touch it's internals. |
I would like Taskfile scoped variables so that the behaviour of the parent taskfile or the included child taskfiles is not implicitly changed just by including a taskfile. This topic was touched on a few times with @andreynering and the latest discussion is in #1006.
You need this in use cases whereby multiple separate Taskfile projects are chained together in a parent/child relationship. And in this case, you don't own or necessarily know the inner details of these lower-layer included taskfiles.
Currently, you have to know every single variable that is globally scoped so that you don't use the same variable name in the parent or child taskfiles. It kind of defeats the purpose of taskfile inclusion to provide abstraction.
The worst is that if you don't go through every taskfile, you won't know when you are using a variable that changes the behaviour somewhere in some taskfile unintentionally.
@andreynering Thanks for the comment on #1006. I agree that for the next major version making variables scoped by Taskfile is a reasonable consideration and design decision, which would make maintaining taskfiles simpler as the behaviour would be a lot more predictable.
The text was updated successfully, but these errors were encountered: