argbash icon indicating copy to clipboard operation
argbash copied to clipboard

Using environment variable by default

Open tcheronneau opened this issue 3 years ago • 0 comments

Hey just discovered this and it's really cool ! But now I find myself with something I would want and I don't find it.

Is there a way to define an argument (no matter the type) to be overwritten by an env variable ?

For example I define for my script some username / password :

./run.sh -u <user> -p <password>

And for some reason I would want this thing to be possible :

PASSWORD=toto ./run.sh -u <user>

But still to have the defaults available. So for example by convention say that user default to admin but if USER is defined use it. From what I've seen in the code it would simply need to overload the init phase of the variables. Maybe not auto activation but some kind of option when you declare the variable ?

tcheronneau avatar Sep 13 '21 07:09 tcheronneau