-
Notifications
You must be signed in to change notification settings - Fork 1
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
[feature request] recursive loading #15
Comments
So I have something that loads a taskfile from the fs recursively. Link to the commit
Also I don't know if recursive loading should be considered a breaking change: it technically allows stuff that would have previously failed, but stuff that already worked will still continue to work. |
I feel like Alfons should move to the directory where the taskfile was found? I think that if I were in a subfolder, and I was loading a taskfile from a folder above, I would have written that taskfile using a project-wide form. If I needed the paths to be local, I would have a local taskfile. At least that's how I see it. I think a flag won't be necessary. And yeah definitely not a breaking change, this would become 4.5. |
I was thinking of taskfiles like this one for local tasks: tasks:
format: =>
sh "fish -c 'clang-format -i **.cpp'"
compile: =>
sh "make"
run: =>
sh "make run"
git: =>
sh "git add ."
sh "git commit -m 'Add subproject #{fs.dirname!\match '[\\/]([^\\/]+)$'}'"
sh "git push" Without moving to the taskfile's directory, that would allow for this to be put in the git root, and used for each subproject of the repo (for monorepos, or class repositories for example), without copying the But arguably this isn't really required, since the tasks can issue However, this raises the question: should |
I'm thinking this could be made easier for the user with a helper function that automatically keeps it in the directory you invoked tasks:
format: =>
relative!
sh "fish -c 'clang-format -i **.cpp'"
compile: =>
relative!
sh "make"
run: =>
relative!
sh "make run"
git: =>
relative!
sh "git add ."
sh "git commit -m 'Add subproject #{fs.dirname!\match '[\\/]([^\\/]+)$'}'"
sh "git push" It sounds like it could be done but I'm not sure how practical it is to implement. I'm also unsure if it should be a separate helper function or something like tasks:
run: =>
mode "relative"
sh "make run"
If you're using |
Alright, I'll look into |
I... guess? But it is something you would never write yourself, since we agreed on no flag to make it relative. I only suggested a |
Alfons currently allows loading a taskfile from a specific path and with a specific language.
This currently allows executing taskfiles located elsewhere in the filesystem, and setting aliases like
alias alm='alfons --file /home/codinget/.alfons/moon.moon'
to run common tasks from everywhere.This feature request would add recursive taskfile loading, that would try loading
Alfons.moon
,Alfons.lua
, then../Alfons.moon
,../Alfons.lua
, then../../Alfons.moon
,../../Alfons.lua
, and recursively until either a taskfile is found, or the root is reached.This would allow for project-wide or multi-project-wide taskfiles to be used from any directory within the project, and applying to the user's current directory.
One use case would be to have a taskfile with common tasks (format, rebuild, clean, package) at the root of a git repository containing several projects, and which could be used with a simple
alfons
invocation.The text was updated successfully, but these errors were encountered: