Thanks to visit codestin.com
Credit goes to github.com

Skip to content

changing cliflagv2 to support variadic forcedinclude parameter#357

Merged
knadh merged 2 commits intoknadh:masterfrom
kooroo:forceinclude_cliflagv2
May 16, 2025
Merged

changing cliflagv2 to support variadic forcedinclude parameter#357
knadh merged 2 commits intoknadh:masterfrom
kooroo:forceinclude_cliflagv2

Conversation

@kooroo
Copy link
Contributor

@kooroo kooroo commented May 5, 2025

proposed change to address #356

this changes the provider function definition to a variadic one that allows passing a []string at the end which lists flags that should be loaded up even if they weren't set explicitly (default values). This should preserve current functionality for any current code using this provider without breaking, but enable calling the provider via

k.Load(cliflagv2.Provider(c, ".", []string{"flag1", "flag3"}), nil)

which will load flag1 and flag3 into the koanf object with whatever they contain (default values, zero values, other shenaniganery and tomfoolery).

@knadh
Copy link
Owner

knadh commented May 9, 2025

I think the better approach is to add a new function ProviderWithConfig(".", Config{..}) and have Config{ Defaults: []string } or something along those lines.

@kooroo
Copy link
Contributor Author

kooroo commented May 14, 2025

I think the better approach is to add a new function ProviderWithConfig(".", Config{..}) and have Config{ Defaults: []string } or something along those lines.

I made changes. Does this fit better with what you were thinking?

you have to load it via something like
k.Load(cliflagv2.ProviderWithConfig(c, ".", &cliflagv2.Config{Defaults: []string{"flag1", "flag3"}}), nil)

@knadh knadh added the enhancement New feature or request label May 16, 2025
@knadh knadh merged commit 6e430e8 into knadh:master May 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants