From 37037357a3096ef1ca38dc6859bff25ed0b3f193 Mon Sep 17 00:00:00 2001 From: Martin Duhem Date: Thu, 18 Dec 2025 17:49:32 +0100 Subject: [PATCH] Fix `help` command arguments parsing Previously, some additional code was used to parse the arguments to the `help` command and ensure that the remaining commands were consistent with the desired state of sbt. While this code worked well in sbt 1.x, and was helpful in getting `sbt help new` to work as expected, this does not work in sbt 2, and is actually not required. This patch removes the additional code, which fixes the `help` command in sbt. --- .../src/main/scala/sbt/BasicCommands.scala | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/main-command/src/main/scala/sbt/BasicCommands.scala b/main-command/src/main/scala/sbt/BasicCommands.scala index 33ed2aebe..fe933815d 100644 --- a/main-command/src/main/scala/sbt/BasicCommands.scala +++ b/main-command/src/main/scala/sbt/BasicCommands.scala @@ -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 =