carueda / cfg Goto Github PK
View Code? Open in Web Editor NEWType safety all the way from configuration spec to configuration access in Scala
License: Apache License 2.0
Type safety all the way from configuration spec to configuration access in Scala
License: Apache License 2.0
I see there is a sbt plugin requirement.. so I'm not hopeful that this can be used with maven .. but checking in any case since this library looks to fit well with our needs - and pureconfig has too many issues.
Cfg
v. 0.0.7
Steps to reproduce behavior
@Cfg
case class WithBackticks(`my-param`: Int = 1)
Expected behavior
Proper handling regarding the config parameter my-param
, so, for example:
val cfg = WithBackticks(ConfigFactory.parseString(
"my-param = 2"
))
cfg.`my-param` ==> 2
Actual behavior
Looking at the macro expansion as done by IDEA:
case class WithBackticks(`my-param`: Int = 1) {}
object WithBackticks {
def apply($cp: _root_.com.typesafe.config.Config): WithBackticks = {
WithBackticks(if ($cp.hasPath("`my-param`")) $cp.getInt("`my-param`") else 1)
}
}
That is, Cfg is not removing the backsticks to access the parameter in the input configuration.
That's the actual bug in Cfg.
Now, there's also a weird behavior when running the test above using sbt:
[error] <macro>:2: ':' expected but identifier found. [error] case class WithBackticks(my-param: Int = 1) {}
Despite the familiar limitations in IDEA re scalameta macros, it seems that it's actually doing better than the corresponding handling from sbt, at least with the scalameta + paradise versions used by Cfg 0.0.7 .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.