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

Specify Taskfile location in environment variable. #1721

Open
shpoont opened this issue Jul 14, 2024 · 4 comments
Open

Specify Taskfile location in environment variable. #1721

shpoont opened this issue Jul 14, 2024 · 4 comments
Labels
area: env Changes related to environment variables. type: enhancement A change to an existing feature or functionality.

Comments

@shpoont
Copy link

shpoont commented Jul 14, 2024

It would be great to have the option to set the path to the Taskfile using an environment variable. This would be particularly useful in scenarios where the Taskfile is not located in the default path (e.g., Taskfile.yaml), allowing us to avoid specifying the path each time.

@task-bot task-bot added the state: needs triage Waiting to be triaged by a maintainer. label Jul 14, 2024
@trulede
Copy link

trulede commented Jul 23, 2024

You can do that and more with the shell:

$ export MYTASKFILE=foo.yaml
$ task --taskfile $MYTASKFILE
stat foo.yaml: no such file or directory
$ alias task='task --taskfile $MYTASKFILE'
$ task
stat foo.yaml: no such file or directory
$ alias task='task --taskfile ${MYTASKFILE:-Taskfile.yml}'
$ unset MYTASKFILE
$ task
stat Taskfile.yml: no such file or directory

More chance that it works too ... the internals of Task are not so easy.

@shpoont
Copy link
Author

shpoont commented Jul 23, 2024

@trulede Thanks, but this is not what I am looking for. Your example would work with single instance of go-task usage. If it is used in multiple places, it would mean that you must find all occurrences of usage of go-task and rewrite them to support this approach which makes this hardly practical.

@vmaerten vmaerten added type: enhancement A change to an existing feature or functionality. area: env Changes related to environment variables. and removed state: needs triage Waiting to be triaged by a maintainer. labels Sep 22, 2024
@trulede
Copy link

trulede commented Sep 29, 2024

@shpoont The alias command does exactly what you wanted. You don't need to rewrite anything, just add the alias and export to your bash profile.

alias task='task --taskfile ${MYTASKFILE:-Taskfile.yml}'
export MYTASKFILE=foo.yaml

That will work everywhere.

IMHO it easier to just name the files Taskfile.yml, that in its own is communicating something.

@shpoont
Copy link
Author

shpoont commented Sep 29, 2024

@trulede I never said that I wanted to run go-task within an interactive bash session. Furthermore, I didn't say that my goal was simply to rename Taskfile.yml.

Your proposed solution requires a POSIX-compliant shell running in interactive mode. This requirement makes it impractical for various scenarios, including scripts using subshells, CI/CD pipelines, running go-task as child process of non-shell program - among other potential use cases.

I'm looking for a proper feature implementation, not a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: env Changes related to environment variables. type: enhancement A change to an existing feature or functionality.
Projects
None yet
Development

No branches or pull requests

4 participants