arctic-hen7 / bonnie

Simple, cross-platform, and fast command aliases with superpowers.
MIT License
83 stars 6 forks source link

Support variables #23

Open arctic-hen7 opened 3 years ago

arctic-hen7 commented 3 years ago

Description A new top-level HashMap [variables], which would allow the derivation of values that can be interpolated into commands. When preparing a command to be run, we'd compute their values (they'd be fully-fledged command cores themselves, their outputs become the values) and interpolate them. We could then store the values we've attained in a temporary HashMap that we pass around to each subcommand etc. so we don't compute any unnecessary values, but we also don't compute any values twice.

Reasoning Make does this excellently, and Bonnie has reached the point where this feature is really a must. I see this as the third type of interpolation in addition to arguments and environment variables.

Are you willing to work on an implementation of this? Yes.

bjesuiter commented 3 years ago

Update:

I found the availability of the env_files = [ ".env" ] key. ^^ This is what I need, I hadn't seen that before. But anyway, dynamic variables from commands sound very exciting and useful!

Original

This is great, it's exactly what I want for my current problem.

I have the following bonnie file:

version = "0.3.2"

[scripts]
    build = "docker build -t \"${TARGET_IMAGE}:latest\" ."
    tag   = "docker tag ${TARGET_IMAGE}:latest ${TARGET_IMAGE}:${MC_BASE_IMAGE_VERSION}"

The problem is, that I need to define these ENV Vars outside of the bonnie.toml and find a way to load them on every bonnie command.

This hashmap feature would solve that problem, since it would pass all HashMap variables into the environment of the bonnie commands!