In nim, you can define a symbol via -d:value and test if it was defined with defined(value). It is possible however to define a key and retrieve its value? I'm looking for something in the vein of --colors:on but user defined.
I also looked for this and didn't find anything for my nim-small-coreutils. I ended up using environment variables as a hack and read them in a nonportable manner:
const colors = staticExec "echo \"$colors\""
when colors == "on":
echo "It's on!"
else:
echo "I guess it's off? The value is: ", colors
This takes the environment variable at compile time, so you can use it like this:
colors=on nim c example
or alternatively:
nim c --putEnv:colors=on c example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With