mirror of
https://github.com/sbt/sbt.git
synced 2026-10-06 10:03:56 +02:00
Merge pull request #4501 from eatkins/multi-command
Allow trailing semicolon in multi commands
This commit is contained in:
@@ -163,7 +163,7 @@ object BasicCommands {
|
||||
)
|
||||
def commandParser = state.map(s => (s.combinedParser & cmdPart) | cmdPart).getOrElse(cmdPart)
|
||||
val part = semi.flatMap(_ => matched(commandParser) <~ token(OptSpace)).map(_.trim)
|
||||
(cmdPart.? ~ part.+).map {
|
||||
(cmdPart.? ~ part.+ <~ semi.?).map {
|
||||
case (Some(h), t) => h.mkString.trim +: t.toList
|
||||
case (_, t) => t.toList
|
||||
}
|
||||
|
||||
@@ -61,5 +61,10 @@ class MultiParserSpec extends FlatSpec with Matchers {
|
||||
"foo bar baz".parseEither shouldBe Left("Expected ';'\nfoo bar baz\n ^")
|
||||
"foo bar baz;".parseEither shouldBe
|
||||
Left("Expected not ';'\nExpected '\"'\nfoo bar baz;\n ^")
|
||||
"foo;".parseEither shouldBe Left("Expected not ';'\nExpected '\"'\nfoo;\n ^")
|
||||
}
|
||||
it should "parse commands with trailing semi-colon" in {
|
||||
"foo;bar;".parse shouldBe Seq("foo", "bar")
|
||||
"foo; bar ;".parse shouldBe Seq("foo", "bar")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@
|
||||
|
||||
# All of the other tests have involved input tasks, so include commands with regular tasks as well.
|
||||
> ~; compile; setStringValue baz; checkStringValue baz
|
||||
# No trailing semicolons are allowed
|
||||
-> ~; compile; setStringValue baz; checkStringValue baz;
|
||||
# Ensure that trailing semi colons work
|
||||
> ~ compile; setStringValue baz; checkStringValue baz;
|
||||
|
||||
Reference in New Issue
Block a user