We can add another declaration called prefix within the env declaration that is used to group prefixed env vars. For example:
const Config = struct {
name: []const u8, // Maps to "APP_NAME" env var
port: u32, // Maps to "APP_PORT" env var
debug: bool = false, // Maps to "APP_DEBUG" env var
timeout: ?f32 = null, // Maps to "APP_TIMEOUT" env var
const env = .{
.name = "NAME",
.port = "PORT",
.debug = "DEBUG",
.timeout = "TIMEOUT",
const prefix = "APP_"
// const suffix = "_TEST"
};
};
const config = try env_struct.load(Config, allocator);
The initial plan is to apply this prefix recursively for nested structs. I'll probably also include support for suffix since, why not?
We can add another declaration called
prefixwithin theenvdeclaration that is used to group prefixed env vars. For example:The initial plan is to apply this prefix recursively for nested structs. I'll probably also include support for suffix since, why not?