better naming + value class

This commit is contained in:
Miklos Martin 2017-10-27 20:10:30 +02:00
parent 79e75f02e5
commit 951c78a4d7
2 changed files with 3 additions and 3 deletions

View File

@ -188,8 +188,8 @@ 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 {
implicit class CommandWithName(val cmd: Command) extends AnyVal {
def nameOption: Option[String] = cmd match {
case sc: SimpleCommand => Some(sc.name)
case _ => None
}

View File

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