Comments (6)
Hi. I'm sorry but I think you need to provide a bit more context. What do you mean by "modification of config files"?
from confique.
In the end, I want to provide a git config
like sub command, that can set and query configuration values. But the need to modify the on disc configuration file can also arise from, e.g. GUI applications that have a settings menu on top of a human-readable on disc configuration file (e.g. VS Code).
from confique.
Ah I see. That makes sense. This is something I very likely will consider for confique
. In fact I might have this exact requirement very soon in one of my own projects in which I plan to use confique. So I will likely see about it then.
However, already now I am not sure how well confique can support it. Just serializing the whole configuration and writing it to the file again is fairly easy, but overwrites the whole file. That means that comments made by the user for example are overwritten. I am not sure confique will ever support this "only change what's necessary but keep the original file as much as possible". It's not easy. Would that be a requirement for you?
But yes, the basic "write an in-memory config to file" will certainly be supported. Likely also with the option to write or not write default values and the like.
from confique.
I would want to keep comments and such, but that would require to not use serde for the writing but a different trait that could ask a Config provider to only write the changes but keep the rest of the file as is without breaking any formatting or comments. For toml this could be achieved with toml-edit
and there are probably similar crates for other file formats, but this increases the custom code to maintain as one cannot rely on the serde infrastructure as much if at all.
from confique.
Yep :/ I am very sure that confique
will stay with serde and not pull in any other dependencies.
from confique.
I experimented a bit, and it looks like it wouldn't be too terrible to do a serde serializer that preservers the original data if possible: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=dbda15adfbdf58defcaf2c5707a3a033
It uses toml-edit
which would already be a dependency through toml
.
Granted this is only a very incomplete implementation for toml
one would need to repeat that for all supported data formats. But maybe there would be a way to design this in a way where these "modifying serializers" could be brought in externally from a confique
consumer.
from confique.
Related Issues (20)
- Express dependencies between fields via attributes (e.g. `requires = "other_field"`)
- Load default values from Rust expressions like constants HOT 1
- Validation HOT 1
- Forward other derives to the partial type? HOT 6
- More file convenience functions ("first found one", `config.{toml,yaml}` syntax, ...)
- Think about interaction with clap to allow loading/overriding config values from CLI args HOT 3
- Feature Request: Template for dotenv configuration format HOT 7
- fmt & clippy & CI HOT 1
- Make `template::format` non-generic and pass `C::META` instead HOT 1
- Warnings about missing docs HOT 5
- Means to customize FormatOptions HOT 2
- Automatic support for `skip_serializing_if` on each field
- Deriving environment variable names from structs HOT 3
- `invalid type: string` when trying to deserialize an enum HOT 1
- Save config as file
- Warning about missing docs (in private items) HOT 1
- env yes|no booleans? HOT 3
- empty strings for env bools HOT 1
- `Hocon` support HOT 2
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 confique.