mehcode / config-rs

⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Apache License 2.0
2.43k stars 206 forks source link

chore: Use a common method in parsers to check root is a table #469

Closed polarathene closed 8 months ago

polarathene commented 9 months ago

Presently there is an approach implemented for JSON5, while other parsers have a TODO comment. I adapted the approach used for the Dhall config support and leveraged it as a common method for ValueKind.

AFAIK, the initial parser call for the text value into a from_* method will handle any earlier failure, while this ensures that parse() returns the expected map from ValueKind::Table. I think this satisfies the TODO?

polarathene commented 9 months ago

@polarathene You're pretty active here, thank you for your contributions!

You're welcome! It's not much but I try lend a hand when I can spare the time.

Maybe you want to have a look?

I would, but I have quite the backlog elsewhere to catchup on 😅 (I'm also not too experienced with Rust)

I just wanted to try pitch in some time to help with the two stale config features, and afterwards I figured these two recent PRs were small enough improvements to throw your way :)

I understand with things taking time and stalling, some of my own are dragging out by 1-2 years, some even longer 😝

polarathene commented 9 months ago

Clippy failures aren't related to this PR, how would you like them resolved?

matthiasbeyer commented 9 months ago

Hm, with 1.70.0, these clippy failures do not appear on master for me? :eyes:

polarathene commented 9 months ago

Hm, with 1.70.0, these clippy failures do not appear on master for me? 👀

They're all on the master branch, this PR doesn't touch these files and the CI is catching them 🤷‍♂️

image

https://github.com/mehcode/config-rs/blob/d7c165602199d045cdee3aab23ff69d7269de7e3/src/builder.rs#L228

https://github.com/mehcode/config-rs/blob/d7c165602199d045cdee3aab23ff69d7269de7e3/src/file/mod.rs#L131

https://github.com/mehcode/config-rs/blob/d7c165602199d045cdee3aab23ff69d7269de7e3/src/value.rs#L164-L169

https://github.com/mehcode/config-rs/blob/d7c165602199d045cdee3aab23ff69d7269de7e3/src/value.rs#L170-L172

matthiasbeyer commented 9 months ago

Ah, yes. I was using 1.70.0, but CI obviously runs 1.73.0.

I will push a fix in a few minutes!

matthiasbeyer commented 9 months ago

After https://github.com/mehcode/config-rs/pull/471 is merged you can rebase for fixes to these issues.