geofffranks / spruce

A BOSH template merge tool
MIT License
433 stars 78 forks source link

feat: default operator #372

Closed oliverbaehler closed 1 year ago

oliverbaehler commented 1 year ago

Hi, love using Spruce :heart:

I have the use case, that I wan't to do some sort of defaulting mechanism. Eg. how envsubst does it ${variable:-"default"}. I was wondering if that's possible with spruce as well? Looking at the operators I don't think one of these is intended to be use like this. A grab fails if a value is not in the structure. But i would like to "handle" that case:

(( default "" $.ctx.proxy ))

Maybe it would even be possible to do nested defaults.

WDYT?