Comments (2)
So, roughly, I think this could work as follows:
- Construct a provider representing data to be written
- Construct a figment to read the config file
- Merge the provider into the figment
- Extract (complete) data from figment
- Write data
But:
- this writes out default values for all parameters not specified via the provider or input file
- this loses any comments in the source
- output order of file bears no resemblance to input order
There are two parts to fixing this:
- filtering data to that which needs to be written, which could perhaps be done with
Figment::find_metadata
but probably requires a new method or usingProvider::data
directly - merging this into the file, in order, and ideally including comments: requires using something like
toml_edit
instead of thetoml
crate
from figment.
Does anything close to that exist, or will I have to roll my own?
Not in this crate, at least not specifically. You could certainly serialize any structure into any kind of format and write it out (as the comment above), but that would mean rewriting the user's config with your own equivalent version which wouldn't maintain formatting. To do so while maintaining formatting is rather specialized, and crates like toml-edit
exist for that reason.
from figment.
Related Issues (20)
- default() merging isnt triggered for values in a HashMap HOT 5
- Env Error conversion number to string HOT 4
- How do you get an absolute path from a `RelativePathBuf`? HOT 9
- Transparent deserialization of newtypes/single value structs HOT 1
- Best way to support an "extends other config" field HOT 2
- error merging using serde alias HOT 3
- Feature request: Automatic extraction based on cargo features HOT 2
- Reading from .env file HOT 2
- Bug in `Value::to_i128` HOT 1
- Feature request: provider for env secret files HOT 5
- Support YAML aliases/anchors HOT 2
- Is this abandoned? HOT 1
- `serde_yaml` version range HOT 1
- Reading single line from file HOT 5
- Unable to prioritise clap arguments over environment variables HOT 2
- How to handle replacement of single config entries inside a nested configuration? HOT 2
- Option to append vectors instead of replacing them. HOT 12
- Feature - set config values by path HOT 4
- Strange behavior with figment.join HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from figment.