-
-
Notifications
You must be signed in to change notification settings - Fork 677
Add special variable for task working directory #2102
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
Comments
I was running into something similar when I came across this. Upon further study, I think Observe. With this Taskfile.yml and an empty subdir:
% task % task --dir subdir % (cd subdir; task) Now create
Now:
So it seems that |
In case I'm right, see #2123. |
Hi @jberkenbilt . Thank you for your detailed response. I think you are indeed right, but I dont see how your observation is different from mine. Maybe it is just wording. So my understanding is was/is:
All I wanted to achieve is to have a special variable which contains the path which has been set with |
Oh, @jaynis, I see. I guess there are really three different things. Suppose you have this Taskfile:
and this directory structure:
If you are in /tmp/z/a/b/c and run
Your first comment says you don't see much of a use case for knowing where task was started from when run with I still think the problem is that Anyway, I don't think what I'm saying contradicts what you're saying; I'm just adding the nuance that I think, regardless of whether the feature you want is there, the documentation for Anyway, I'm new here -- I just started playing with taskfile today and don't have any connection with the project. :-) |
Well, as you must have noticed in your PR, strictly speaking the I agree that having a variable which contains the directory from which task has been called from ( |
Hi @jaynis, I gave this some thought, and I decided to go in a slightly different route. The whole purpose of This looked much simpler to be than adding yet another special variable, which would confuse in the end. |
Hi @andreynering and thank you for your explanation, but with the change you have made it is no longer possible to execute a task from a Suppose you have a central I agree that there are already quite some special variables, but overall I in fact think it would be useful to have:
|
@andreynering I don't think this is correct. The purpose of However, I do agree that we need to think carefully about the naming of our variables as we now have a lot of special variables to represent various directories. I actually suggest that we revert this until we've had more time to discuss. |
This comment has been minimized.
This comment has been minimized.
@jaynis Random thought. My understanding is that you want this value to always match the value given by the If this is the case, then |
Description
There are various special variables available but none of them reflects the working directory of a respective task. The ones that come closest are:
USER_WORKING_DIR
which contains the directory where task has been called from, but does not honor the-d <dir>
command line parameterand
TASK_DIR
which merely contains what has been configured underdir:
in a task of theTaskfile.yml
file and does not even resolve template expressions.I see two different solutions to this problem:
Either change the behavior ofUSER_WORKING_DIR
so that it takes the-d
parameter into account, because I see only very little benefit in having a variable which contains the directory where task has been called from when a different working directory has been explicitly set with-d
TASK_WORKING_DIR
which contains the desired dir and does not break the current behavior ofUSER_WORKING_DIR
.The current use case which I have is as follows: I have a root directory containing a
Taskfile.yml
file and some subdirectories which doesnt haveTaskfiles.yml
files. I now want to reuse the logic of theTaskfile.yml
from the root directory in the subdirectories as described here. This works well if I navigate to a subdirectory and call the respective task from there, however, when I call task from the root directory and specify the subdirectory with the-d
parameter it doesnt work asUSER_WORKING_DIR
still contains the root directory as outlined above.The text was updated successfully, but these errors were encountered: