Can you access a SBT SettingKey inside a Command?

前端 未结 1 1364
既然无缘
既然无缘 2021-01-14 03:43

I am writing a Command and want to use the Logger in TaskStreams but this is not possible since you cannot access .value of a SettingK

相关标签:
1条回答
  • 2021-01-14 04:08

    streams is intended for tasks, not commands.

    So one way is to create a "holder" TaskKey and get a stream of that, for instance sbt-pgp creates and uses pgpCmdContext - see the definition of pgp-cmd.


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

    val myCommand = Command.single("myCommand") { case (s, arg) =>
      val extracted = Project extract s
      val log = extracted get sLog
      log info "Some logging"
      currentState
    }
    
    0 讨论(0)
提交回复
热议问题