Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: support standard library flag provider #225

Closed
beihai0xff opened this issue Aug 18, 2023 · 3 comments
Closed

Proposal: support standard library flag provider #225

beihai0xff opened this issue Aug 18, 2023 · 3 comments

Comments

@beihai0xff
Copy link

I use the golang standard library flag to parse command line parameters, for which I implements a stdflag Provider

The stdflag Provider parses the command line parameters into a map[string]interface{} and then passes it to koanf.

Similar to the posflag Provider, if a key already exists in koanf and also exists in flagset, but the value in flagset is the default value, then the key will not be overwritten
The stdflag Provider also provides a callback function to modify the key and value of the command line parameters.

If you interested in this, I can submit a PR to add this Provider to koanf.
you can read the code here: Add new stdflag provider for reading command line parameters

@knadh
Copy link
Owner

knadh commented Aug 31, 2023

Thanks @beihai0xff. Couldn't this functionality be added as optional behaviour to the bundled basicflag provider?

@beihai0xff
Copy link
Author

beihai0xff commented Sep 6, 2023

Couldn't this functionality be added as optional behaviour to the bundled basicflag provider?

Sorry, I didn't see the basicflag Provider. I will merge stdflag Provider to basicflag Provider.

@beihai0xff
Copy link
Author

#230 I create a PR

@knadh knadh closed this as completed Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants