mirror of https://github.com/sbt/sbt.git
[2.x] fix: Allow ++ command to accept project/command patterns not in current state (#8505)
When using '++version project/task', the parser now accepts project/command patterns (e.g., 'docs/docusaurusPublishGhpages') even if the project doesn't exist in the current state. This is achieved by adding a fallback parser that accepts any 'project/command' pattern alongside the combinedParser. Previously, '++2.12.19 docs/task' would fail with 'Project not found' if 'docs' project wasn't available in the current Scala version, but '++2.12.19; docs/task' worked. Now both syntaxes work correctly. The fix is targeted to only accept slash-delimited patterns, avoiding interference with other parser components like the -v verbose flag. Fixes #7574
This commit is contained in:
parent
106b8b9978
commit
847703cd5e
|
|
@ -58,7 +58,11 @@ object Cross {
|
|||
}
|
||||
val spacedVersion = if (spacePresent) version else version & spacedFirst(SwitchCommand)
|
||||
val verboseOpt = Parser.opt(token(Space ~> "-v"))
|
||||
val optionalCommand = Parser.opt(token(Space ~> matched(state.combinedParser)))
|
||||
// Accept valid commands, or project/command patterns that may reference projects
|
||||
// not yet available after version switch (fixes #7574)
|
||||
val slashCommand = (NotSpace ~ ('/' ~> any.+)).map { case p ~ c => p + "/" + c.mkString }
|
||||
val commandParser = state.combinedParser | slashCommand
|
||||
val optionalCommand = Parser.opt(token(Space ~> matched(commandParser)))
|
||||
val switch1 = (token(Space ~> "-v") ~> (Space ~> version) ~ optionalCommand) map {
|
||||
case v ~ command =>
|
||||
Switch(v, true, command)
|
||||
|
|
|
|||
Loading…
Reference in New Issue