Giter Club home page Giter Club logo

Comments (2)

dhardy avatar dhardy commented on May 22, 2024

So, roughly, I think this could work as follows:

  1. Construct a provider representing data to be written
  2. Construct a figment to read the config file
  3. Merge the provider into the figment
  4. Extract (complete) data from figment
  5. 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 using Provider::data directly
  • merging this into the file, in order, and ideally including comments: requires using something like toml_edit instead of the toml crate

from figment.

SergioBenitez avatar SergioBenitez commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.