rliebz / tusk

The modern task runner
https://rliebz.github.io/tusk/
MIT License
236 stars 21 forks source link

make the program launch directory available as a variable #84

Closed robinbryce closed 3 years ago

robinbryce commented 3 years ago

Is your feature request related to a problem? Please describe.

I want to be able to pass relative paths in options and resolve them against the current working directory of the user when they invoke tusk. So I can do things like

openssl --key ${launchdir}${userpath}

Describe the solution you'd like

A well known variable that I can reference using the existing syntax would be fine. Or a pointer to how to do this with current tusk

robinbryce commented 3 years ago

My current work around is to have a workdir option then invoke

tusk -f tusk.yml get -w $(pwd) mytask key.pem

Via an alias to take care of the -w bit

rliebz commented 3 years ago

The environment variables are evaluated before the working directory is changed, so you can actually capture the value of $PWD as an option. For example:

tasks:
  pwd:
    options:
      dir:
        environment: PWD
    run: echo ${dir}
robinbryce commented 3 years ago

Ah, lovely. Thanks!