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

Question: Iterator over values and best practices for modification of config #65

Closed
jasal82 opened this issue Feb 28, 2023 · 2 comments
Closed

Comments

@jasal82
Copy link

jasal82 commented Feb 28, 2023

First of all, thank you very much for the library. It has already saved me a lot of time. Now my questions: I want to list the sources of all settings, similar to the output of git config --list --show-origin. Is there a way to iterate over all values in the figment? Also I'd like to be able to set config settings on different levels, much like --global and --local in git. What is the easiest way to do this, keeping the figment up-to-date at the same time? Ideally I'd want to be able to modify the value on the figment and serialize back to the source files depending on the location metadata.

@SergioBenitez
Copy link
Owner

SergioBenitez commented Apr 1, 2023

Hey! Sorry I didn't get to this until now. I must have missed it.

I want to list the sources of all settings, similar to the output of git config --list --show-origin. Is there a way to iterate over all values in the figment?

Yes. If you just want the sources, use get_metadata(). If you want all of the values in a Figment, use data() then use the tag() for each Value to look up its Metadata.

Also I'd like to be able to set config settings on different levels, much like --global and --local in git. What is the easiest way to do this, keeping the figment up-to-date at the same time?

I'm not sure I understand this question. Can you be a bit more specific? Perhaps with a concrete example?

Ideally I'd want to be able to modify the value on the figment and serialize back to the source files depending on the location metadata.

If you merge() or join() on an existing figment, then its data() will be updated. The return value from data() is Serialize, so you can use any format you want and write it to a file. You could also extract() into any Deserialize type that you want, which you could then write wherever you want.

@SergioBenitez
Copy link
Owner

Hopefully the above fully answered your question! Do let me know if that's not the case.

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