casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
18.75k stars 426 forks source link

Feature request: pre-script and post-script #2178

Open xingheng opened 3 weeks ago

xingheng commented 3 weeks ago
_setup_:
    echo "setup recipe will run BEFORE any other recipe gets triggered"

run cmd:
    echo "do something"

_teardown_:
    echo "teardown recipe will run AFTER any other recipe gets triggered"
casey commented 3 weeks ago

I think this would be pretty easy to add with a [setup] and [teardown] attribute. Modules make this more complex though. If you have a single justfile, then [setup] and [teardown] should obviously get executed whenever you run a recipe. But if you reference submodules, should the [setup] and [teardown] functions in those submodules also run whenever you run a recipe, or only when you run a recipe from that submodule?

xingheng commented 3 weeks ago

It seems the setup and teardown attributes didn't implement yet, sorry for that I'm not good at rust. Currently I worked on a single justfile, if it's referred as a submodule, the functions should be valid for recipes which containing in the current module justfile, I think.