clarinet icon indicating copy to clipboard operation
clarinet copied to clipboard

Don't overwrite `Clarinet.toml` when adding requirements

Open hstove opened this issue 2 years ago • 2 comments

For a new version of Clarigen (a Clarity dev tool) I'm working on, I'm trying to make integration with Clarinet as tight as possible. As part of that, I've moved from having a custom config file to putting config inside Clarinet.toml. However, when testing out the newer "requirements" feature, I noticed my TOML config got overridden after running clarinet requirements add .... I imagine the source code understands all "valid" config options, and just writes a new toml with Clarinet-known config.

Can we change this to support "unknown" config, too? Or, maybe we can allow for a [clarigen] section which is kept? I can provide a list of "known" keys if it's easier to update your code for that. I don't have docs on it at the moment, but I'm happy to make this change if it's agreeable.

hstove avatar Jun 20 '22 20:06 hstove

#246

hugocaillard avatar Jun 21 '22 14:06 hugocaillard

It makes sense yes! This issue has been raised in the past with https://github.com/hirosystems/clarinet/issues/246 and more recently on Discord, it's a one liner but the bulk of this patch would be to make sure that the lib we're using is still considering:

[project.contract]
...

[project.contract]
...

[clarigen]

[project.contract]
...

as a valid TOML. Changes should be minimal, and would be happening in this section of the codebase: https://github.com/hirosystems/clarinet/blob/be49466711e39d44ffbdbf654c35eb2edc599d49/src/frontend/cli.rs#L1267-L1381

lgalabru avatar Jun 21 '22 18:06 lgalabru

Switching from toml to toml_edit could help - https://github.com/toml-rs/toml

lgalabru avatar Jun 08 '23 13:06 lgalabru