paradigmatic / Configrity

Simple, immutable and flexible configuration library for scala.
Other
132 stars 19 forks source link

Configuration setting source precise reporting #16

Open lalloni opened 12 years ago

lalloni commented 12 years ago

When building an application with complex configuration read from many sources it is desirable being able to report precisely on the source location of any given setting when appropriate.

For example when reporting configuration errors it is highly desirable being able to report precisely the source of the conflicting setting to facilitate fixing the situation.

Another example is when reporting some collection of configuration settings for user checking.

I believe for input formats, the "precise source" of the setting would be a pair of location of resource and line number from where the setting effective value has been read.

paradigmatic commented 12 years ago

Interesting feature. The following API could do the trick:

sealed trait Source
case object NA extends Source
case class Resource( name: String, lineNumber: Int )

//in Configuration class
// returns None if the key does not exists
def getSource( key: String ): Option[Source] = ...

It should be possible to implement it, by including another map in the Configuration class storing the key->source relationship. It is also possible to retrieve the line number with the scala parsers. So it could be easy to add it to the standard formats. However, it will require a lot of work with other formats like YAML.

lalloni commented 12 years ago

Sounds like a plan... If I get some spare time I might give it a shot.