diff --git a/main-command/src/main/scala/sbt/Command.scala b/main-command/src/main/scala/sbt/Command.scala index f90aedc8e..53158daa4 100644 --- a/main-command/src/main/scala/sbt/Command.scala +++ b/main-command/src/main/scala/sbt/Command.scala @@ -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( diff --git a/sbt/src/sbt-test/actions/command-name/build.sbt b/sbt/src/sbt-test/actions/command-name/build.sbt new file mode 100644 index 000000000..374a7d3cd --- /dev/null +++ b/sbt/src/sbt-test/actions/command-name/build.sbt @@ -0,0 +1,5 @@ +val command = Command.command("noop") { s => s } + +TaskKey[Unit]("check") := { + assert(command.nameOption == Some("noop"), """command.commandName should be "noop"""") +} diff --git a/sbt/src/sbt-test/actions/command-name/test b/sbt/src/sbt-test/actions/command-name/test new file mode 100644 index 000000000..15675b169 --- /dev/null +++ b/sbt/src/sbt-test/actions/command-name/test @@ -0,0 +1 @@ +> check