mirror of
https://github.com/sbt/sbt.git
synced 2026-09-03 01:23:37 +02:00
Add commandName as an extension method in Command
This commit is contained in:
@@ -187,6 +187,13 @@ object Command {
|
||||
|
||||
def spacedC(name: String, c: Parser[Char]): Parser[String] =
|
||||
((c & opOrIDSpaced(name)) ~ c.+) map { case (f, rem) => (f +: rem).mkString }
|
||||
|
||||
implicit class CommandWithName(cmd: Command) {
|
||||
def commandName: Option[String] = cmd match {
|
||||
case sc: SimpleCommand => Some(sc.name)
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
trait Help {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
val command = Command.command("noop") { s => s }
|
||||
|
||||
TaskKey[Unit]("check") := {
|
||||
assert(command.commandName == Some("noop"), """command.commandName should be "noop"""")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
> check
|
||||
Reference in New Issue
Block a user