Instead of representing the on and off states with x
or
, what about using y
for yes and n
for no?
object Test {
val y = true
val n = false
class DefaultConfigValue[U](val v: U)
implicit class ConfigValue[U](v: U) {
def y = v
def n(implicit default: DefaultConfigValue[U]) = default.v
}
implicit val defaultConfigString = new DefaultConfigValue("")
}
import Test._
import language.postfixOps
val delete = y
val force = n
val res1 = "my first string" y
val res2 = "my second string" n
Notice how you can import postfixOps
and then just add extra whitespace to align all the y
s and n
s for your string configuration options into the same column.
I'm not sure if this makes sense, but I wrote the above code such that you should be able to use any type (not just strings) for the options with the y
and n
postfix operators. All you have to do to enable a new type is create an implicit DefaultConfigValue
for that type so that the no option has something to return.