v0.1.3 added unknown cli flag handling, dependency update

This commit is contained in:
2026-07-18 17:42:35 -04:00
parent f4a19aa72a
commit 389121f7ad
5 changed files with 30 additions and 13 deletions
+9 -3
View File
@@ -435,7 +435,7 @@ func (c *Config) loadEnv(opts LoadOptions) error {
transform = defaultEnvTransform(opts.EnvPrefix)
}
// -- 1. Prepare data (Read-Lock to get paths)
// 1. Prepare data (Read-Lock to get paths)
c.mutex.RLock()
paths := make([]string, 0, len(c.items))
for p := range c.items {
@@ -443,7 +443,7 @@ func (c *Config) loadEnv(opts LoadOptions) error {
}
c.mutex.RUnlock()
// -- 2. Process env vars (No Lock)
// 2. Process env vars (No Lock)
foundEnvVars := make(map[string]string)
for _, path := range paths {
if opts.EnvWhitelist != nil && !opts.EnvWhitelist[path] {
@@ -506,6 +506,9 @@ func (c *Config) loadCLI(args []string) error {
c.cliData = flattenedCLI
// Reset per load; reloads must not accumulate duplicates
c.unknownCLIKeys = c.unknownCLIKeys[:0]
for path, value := range flattenedCLI {
if item, exists := c.items[path]; exists {
if item.values == nil {
@@ -514,6 +517,9 @@ func (c *Config) loadCLI(args []string) error {
item.values[SourceCLI] = value
item.currentValue = c.computeValue(item)
c.items[path] = item
} else {
// Record CLI keys that match no registered path
c.unknownCLIKeys = append(c.unknownCLIKeys, path)
}
}
@@ -693,4 +699,4 @@ func detectFormatFromContent(data []byte) string {
}
return ""
}
}