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

allow import <variable-name> #1975

Open
Ziqi-Yang opened this issue Mar 24, 2024 · 3 comments
Open

allow import <variable-name> #1975

Ziqi-Yang opened this issue Mar 24, 2024 · 3 comments

Comments

@Ziqi-Yang
Copy link

For example:

import? join(config_directory(), "mpm/root.just")
@Ziqi-Yang
Copy link
Author

Ziqi-Yang commented Mar 24, 2024

The same need for all set variables, like:

set dotenv-path := "" + MPM_CONFIG_DIR + "/config"

I want to create an application mainly using just. Currently I can only do things like import? '~/.mpm.root.just', which is awkward.

@JonathanDoughty
Copy link

JonathanDoughty commented Apr 28, 2024

The inability to do variable (or environment variable) substitution for import paths ended up preventing me from a desired DRYing out of Justfile content as well, rather than having to duplicate a Justfile name that I want to include as part of replicating a subset of local contents.

It appears that just's GRAMMAR (currently) accepts only strings for imports as well as modules; so not sure if there is any easy way to implement this without big impacts.

@casey
Copy link
Owner

casey commented May 19, 2024

I can see why this is desirable, but it's tough at the implementation level. Justfiles are statically analyzed before anything runs, including any expression evaluation. I would like to support this, but not at the cost of making the implementation much more complicated.

#1849 partially fixes this, since it allows for expanding environment variables inside of import paths, although it doesn't support arbitrary expressions, and environment variables are loaded without taking into account things like export statements and .env files.

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