Can you access the SBT SettingKey inside the team?

I am writing a command and want to use Logger in TaskStreams , but this is not possible, since you cannot access the .value the SettingKey parameter in the command. Is there any way?

 def myCommand = Command.single("myCommand") { case (currentState, userInput) => val extracted = Project.extract(currentState) val log = streams.value.log <--- not allowed log.info("Some logging") currentState } 
+3
source share
1 answer

streams is for tasks, not teams.

Thus, one way is to create a TaskKey "holder" and get a stream from it, for example sbt-pgp creates and uses pgpCmdContext - see the definition of pgp-cmd .


Another way is to use sLog , but I'm not sure if sLog should be used sLog :

 val myCommand = Command.single("myCommand") { case (s, arg) => val extracted = Project extract s val log = extracted get sLog log info "Some logging" currentState } 
+3
source

Source: https://habr.com/ru/post/982805/


All Articles