task icon indicating copy to clipboard operation
task copied to clipboard

Specify Taskfile location in environment variable.

Open shpoont opened this issue 1 year ago • 4 comments

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.

shpoont avatar Jul 14 '24 17:07 shpoont

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.

trulede avatar Jul 23 '24 19:07 trulede

@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.

shpoont avatar Jul 23 '24 23:07 shpoont

@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.

trulede avatar Sep 29 '24 17:09 trulede

@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.

shpoont avatar Sep 29 '24 22:09 shpoont