mirror of https://github.com/sbt/sbt.git
Merge pull request #3671 from miklos-martin/1.x
Add nameOption to the Command trait
This commit is contained in:
commit
9232a8fbc8
|
|
@ -25,6 +25,11 @@ sealed trait Command {
|
||||||
|
|
||||||
def tags: AttributeMap
|
def tags: AttributeMap
|
||||||
def tag[T](key: AttributeKey[T], value: T): Command
|
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(
|
private[sbt] final class SimpleCommand(
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
val command = Command.command("noop") { s => s }
|
||||||
|
|
||||||
|
TaskKey[Unit]("check") := {
|
||||||
|
assert(command.nameOption == Some("noop"), """command.commandName should be "noop"""")
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> check
|
||||||
Loading…
Reference in New Issue