casey / just

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

Variables defined in a submodule should be overridable on the command line #2119

Open lisongmin opened 1 month ago

lisongmin commented 1 month ago

I have following justfile in the same directory:

var.just

compose_provider := 'podman'

test.just

import 'var.just'

show:
  @echo "compose_provider is {{ compose_provider }}"

Justfile

import 'var.just'
mod test 'test.just'

show:
  @echo "compose_provider is {{compose_provider}}"

And when i set the compose_provider from command line, the show recipe in the Justfile is changed as expect

❯ just --unstable compose_provider=nerdctl show
compose_provider is nerdctl

but the show recipe in the test module always show the default value

❯ just --unstable compose_provider=nerdctl test show
compose_provider is podman

The just version is 1.27.0

casey commented 1 month ago

This is currently not possible. On the CLI, only variables in the root justfile can be overridden, but it would be nice to be able to override submodule variables.

lisongmin commented 1 month ago

Thanks for the quick reply. And now I workaround by using the environment

compose_provider := env('COMPOSE_PROVIDER', 'podman')