import typetraits, options, tables, serialization, ./utils type EnvvarWriter* = object prefix: string key: seq[string] proc init*(T: type EnvvarWriter, prefix: string): T = result.prefix = prefix proc writeValue*(w: var EnvvarWriter, value: auto) = mixin enumInstanceSerializedFields, writeValue, writeFieldIMPL # TODO: reduce allocation when value is (SomePrimitives or range or string): let key = constructKey(w.prefix, w.key) setValue(key, value) elif value is Option: if value.isSome: w.writeValue value.get elif value is (seq or array or openArray): when uTypeIsPrimitives(type value): let key = constructKey(w.prefix, w.key) setValue(key, value) elif uTypeIsRecord(type value): let key = w.key[^1] for i in 0..