Merge pull request #3671 from miklos-martin/1.x

Add nameOption to the Command trait
This commit is contained in:
Dale Wijnand 2017-11-03 08:33:52 +00:00 committed by GitHub
commit 9232a8fbc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,11 @@ sealed trait Command {
def tags: AttributeMap
def tag[T](key: AttributeKey[T], value: T): Command
def nameOption: Option[String] = this match {
case sc: SimpleCommand => Some(sc.name)
case _ => None
}
}
private[sbt] final class SimpleCommand(

View File

@ -0,0 +1,5 @@
val command = Command.command("noop") { s => s }
TaskKey[Unit]("check") := {
assert(command.nameOption == Some("noop"), """command.commandName should be "noop"""")
}

View File

@ -0,0 +1 @@
> check