From 0780a6c08a77c918363c5503183bdf81a69b0d2d Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Mon, 17 Jun 2013 12:06:13 -0400 Subject: [PATCH] Key parsing improvements. Ref #776. * Explain context of expected ':' and '/' error messages * Restore strict project ID parsing to get proper message about invalid project ID --- main/src/main/scala/sbt/Act.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/Act.scala b/main/src/main/scala/sbt/Act.scala index c72ae69fc..7689b2d4d 100644 --- a/main/src/main/scala/sbt/Act.scala +++ b/main/src/main/scala/sbt/Act.scala @@ -115,7 +115,10 @@ object Act opt match { case Some(t) => Select(t); case None => ifNone } def config(confs: Set[String]): Parser[ParsedAxis[String]] = - token( (GlobalString ^^^ ParsedGlobal | value(examples(ID, confs, "configuration")) ) <~ ':' ) ?? Omitted + { + val sep = ':' !!! "Expected ':' (if selecting a configuration)" + token( (GlobalString ^^^ ParsedGlobal | value(examples(ID, confs, "configuration")) ) <~ sep ) ?? Omitted + } def configs(explicit: ParsedAxis[String], defaultConfigs: Option[ResolvedReference] => Seq[String], proj: Option[ResolvedReference], index: KeyIndex): Seq[Option[String]] = explicit match @@ -197,11 +200,12 @@ object Act def projectRef(index: KeyIndex, currentBuild: URI): Parser[ParsedAxis[ResolvedReference]] = { val global = token(GlobalString ~ '/') ^^^ ParsedGlobal - global | value(resolvedReference(index, currentBuild, '/')) + val trailing = '/' !!! "Expected '/' (if selecting a project)" + global | value(resolvedReference(index, currentBuild, trailing)) } def resolvedReference(index: KeyIndex, currentBuild: URI, trailing: Parser[_]): Parser[ResolvedReference] = { - def projectID(uri: URI) = token( examples(ID, index projects uri, "project ID") <~ trailing ) + def projectID(uri: URI) = token( examplesStrict(ID, index projects uri, "project ID") <~ trailing ) def projectRef(uri: URI) = projectID(uri) map { id => ProjectRef(uri, id) } val uris = index.buildURIs