casey / just

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

Is it possible to persist some variables for next just commands? #1960

Closed ccxuy closed 2 months ago

ccxuy commented 2 months ago

I want to do something like this:

a=1
b=2
just a=1 b=2 modA funcB

(I thinksjust modA funcB a=1 b=2is better)

what I could do now is

export a=1
export b=2
just modA funcB

(which call funcB $a $b, but this would pass variables over all receipts)

maybe some other better way to do this is

just save config1 a=1 b=2
just load config1 modA funcB

if we can determin scope and namespace of variable is better

casey commented 2 months ago

I think maybe a .env file would work for you:

$ cat justfile
set dotenv-load

foo:
  echo $A
$ cat .env
A=2
$ just
echo $A
2
ccxuy commented 2 months ago

How to auto save dotenv? Besides some gramma seems not fully compatible, but source .env in every recipes work.

just --unstable show_basic
error: Failed to load environment file: Error parsing line: '([0]="2" [1]="11")', error at line index: 9
Failed at 35: just --unstable show_basic

@casey