I have this simple command that changes the value of myBoolSetting
:
commands += Command("mycommand") {
state ⇒ (Space ~> Bool).?
} { (state, arg) ⇒
val b = arg.getOrElse(true)
Project.extract(state).append(Seq(myBoolSetting in Global := b), state)
}
When I change invoke it does change myBoolSetting
but I lose any setting whose value has been changed by means of the set command
.
> set myStringSetting := "new value"
> myCommand false
In this example, the value of myStringSetting
has been lost and has its default value.
How can I change a setting and keep manual changed settings?
UPDATE:
Found related question: Why sbt.Extracted remove the previously defined TaskKey while append method?, but seems not to work in my case.
Modified code:
commands += Command("mycommand") {
state ⇒ (Space ~> Bool).?
} { (state, arg) ⇒
val b = arg.getOrElse(true)
val session = Project.session(state)
val state2 = Project.extract(state).append(Seq(myBoolSetting in Global := b), state)
SessionSettings.reapply(session, state2)
}