Open Splines opened 3 months ago
I think this would be great. I can imagine a few options that might be useful:
The syntax could be:
# default value
set working-dir := default
set working-dir := self
# use the working directory of the parent module
set working-dir := parent
# use the working directory of the root justfile
set working-dir := root
# use some other working directory
set working-dir := "some/other/directory"
This is probably related to #2273 and the respective PR #2283.
set working-dir := "some/other/directory"
So we're still lacking the ability to use the working directory of a parent justfile.
I think the best syntax for using the working directory of the parent is:
set working-dir := super
However, I'd like to keep the door open for eventually allowing the use of a variable. I.e.:
set working-dir := foo
just
currently doesn't allow the use of variables in settings, since settings may affect how backticks and the shell(…)
function run, including their working directory and exported variables.
So, this syntax:
set working-dir := super
Would change meaning if the RHS of a setting became an expression:
super := "hello"
set working-dir := super
One option is to use some kind of syntax which isn't a valid expression:
set working-dir := @super
set working-dir := super.working_dir
set working-dir := super::working_dir
set working-dir := super->working_dir
set working-dir := super#working_dir
set working-dir := super@working_dir
This is a bit wonky, but the fact that expressions can't be used in setting values has been an issue many times, so I wouldn't want to preclude fixing it.
This is all horrifically complicated by the fact that variables, recipes, and settings can all have the same name.
It'd be great to have an option to treat all paths in a submodule relative to the directory containing the root
.justfile
. I think I'd prefer a per-module flag for this instead of a global one.This would allow me to let my submodules reside in other file locations (e.g. in a folder
.config/commands/
), while not having to issue acd {{justfile_directory()}}
orcd ../../
at the beginning of every recipe.