eddelbuettel / rcpptoml

Rcpp Bindings to C++ parser for TOML files
GNU General Public License v2.0
36 stars 9 forks source link

thoughts some custom parsers which can wrap around rcpptoml #34

Closed sahilseth closed 1 year ago

sahilseth commented 5 years ago

hi @eddelbuettel, I recently found out about toml, and really like the clean definition.

A while back I had written a pkg params, which we heavily use in flowr. We are using tsv files for configuration, to make it simple instead of yaml etc. However, toml, strikes a much better balance.

I would appreciate your thoughts on being able to update values, in a sequential manner.

Imagine a scenario of baseline configuration, and then add some project specific configurations. We would like to update the values, by loading new files. We achieved this in params via the following:

library(params)
#> Loading required package: whisker

# create a new env for params:
opts = params::new_opts()

# currently this is empty
opts$get()
#> named list()
#> attr(,"class")
#> [1] "opts" "list"

# one can load a tsv, of key  value using
# opts$load("conf_base.tsv")
# opts$load("conf_project1.tsv")

# as a simpler example can use this `options` in R
# this exact rendering is followed when loading files as well.
# set some values
opts$set(
  name = "mytool",
  basepath = "~/apps/mytool", 
  binpath = "{{{basepath}}}/bin")

# get the values:
opts$get("binpath")
#> [1] "~/apps/mytool/bin"

# update a path
opts$set(name = "newtool")

opts$get("name")
#> [1] "newtool"

Created on 2019-04-19 by the reprex package (v0.2.1)

eddelbuettel commented 5 years ago

Good questions.

We encountered the idea of better support for baseline configurations as well. I had lobbed that at the time at @dcdillon who found it intriguing enough to generalize it to a whole stream processor: https://github.com/dcdillon/includize

I am still not sure all this should go. Obviously a more general solution in TOML proper would be ideal, but then I waited several years to get better date time support (which we now have). We could also lobby Chase for inclusion in cpptoml but he is probably less than thrilled to depart from a standard.

In work in a different environment now where JSON rules (blech!) and I just post-process in R. Maybe that would actually be easiest for you too?

eddelbuettel commented 1 year ago

Closing this for being stale. We will update to using toml++ soon, maybe you want to look into updating with it.