mirror of https://github.com/sbt/sbt.git
Add commandName as an extension method in Command
This commit is contained in:
parent
12c2e9b8e7
commit
8dacb72f9d
|
|
@ -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
|
||||
Loading…
Reference in New Issue