Merge pull request #8423 from Duhemm/help-arg-parsing

[2.x] Fix `help` command arguments parsing
This commit is contained in:
eugene yokota 2025-12-18 21:14:40 -05:00 committed by GitHub
commit 7fb942ee5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 16 deletions

View File

@ -129,25 +129,11 @@ object BasicCommands {
}
def runHelp(s: State, h: Help)(arg: Option[String]): State = {
val (extraArgs, remainingCommands) = s.remainingCommands match {
/*
exec.commandLine.endsWith(Shell) is done to allow shells other than original shell works correctly with help command.
It's assumed here that shell name must end with "shell" suffix which is true for e.g. shell, oldshell or idea-shell (https://github.com/JetBrains/sbt-idea-shell/blob/072b10e405860feb834402563773f12976be34b9/src/main/scala/org/jetbrains/sbt/constants.scala#L7)
*/
case xs :+ exec if exec.commandLine.endsWith(Shell) => (xs, exec :: Nil)
case xs => (xs, nil[Exec])
}
val topic = (arg.toList ++ extraArgs.map(_.commandLine)) match {
case Nil => none[String]
case xs => xs.mkString(" ").some
}
val message =
try Help.message(h, topic)
try Help.message(h, arg)
catch { case NonFatal(ex) => ex.toString }
System.out.println(message)
s.copy(remainingCommands = remainingCommands)
s
}
def completionsCommand: Command =