Share settings between modules
Currently, when using import, import happens into the parent justfile, so imports can use all the variables as well as the options that are set with set like shell, etc.
However, when another justfile is used as a module, this module entirely lives in it's own scope. While variables can atleast be exported in the parent and reexamined in the module with shell("echo $VARIABLE"), there is currently no way for options to be carried on.
This makes it challenging to use in many scenarios.
Context: I'm trying to build a mono-repo, with just as the task runner. Experiment here: https://github.com/prasannavl/monorepo-experiments/tree/main/just-refined
- The variables
WORKSPACE_OUT,WORKSPACE_ROOTare exported. However,shelloption needs to be set at each and every module, which might defeat the purpose in many aspects.
Hi @prasannavl, @casey,
I think the best way to address your valid point is introduce an optional keyword or mechanism (e.g., inherit_options) that enables transitive inheritance of options from a parent justfile to any module justfiles it imports.
When this feature is enabled, all set options defined in the parent justfile (such as set shell := "bash", set quiet := true, etc.) would be automatically applied to imported modules, unless explicitly overridden within a module.
So the example I've made is the following:
set shell := "bash"
set quiet := true
I think by introducing an inherit_options keyword or similar functionality, "just" would be significantly more usable in modular setups like monorepos.
It would allow for transitive propagation of options without sacrificing flexibility or requiring repetitive definitions.
Cheers, Montana.
Thanks for opening this issue! There should definitely be a way to share settings between modules.
There are kind of two ways to go about it:
-
A setting in a parent module which causes child modules to inherit settings
-
A setting in a child module which causes it to inherit settings from the parent.
-
is probably more convenient, because you only need to set it in the root file, and not in any children. Not sure if 2. is also useful, but wanted to mention it as well.
inherit_options and inherit_envvar options in module would be very helpful