Skip to content
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

Share settings between modules #2271

Open
prasannavl opened this issue Jul 24, 2024 · 2 comments
Open

Share settings between modules #2271

prasannavl opened this issue Jul 24, 2024 · 2 comments

Comments

@prasannavl
Copy link

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_ROOT are exported. However, shell option needs to be set at each and every module, which might defeat the purpose in many aspects.
@Montana
Copy link

Montana commented Oct 21, 2024

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.

@casey casey changed the title Transitive options when using modules Share settings between modules Oct 30, 2024
@casey
Copy link
Owner

casey commented Oct 30, 2024

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:

  1. A setting in a parent module which causes child modules to inherit settings

  2. A setting in a child module which causes it to inherit settings from the parent.

  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants