def ideaShell: Command = Command.command()

in src/main/scala-sbt-1+/org/jetbrains/sbt/pluginCommands.scala [14:34]


  def ideaShell: Command = Command.command(IdeaShellCommandString, Help.more(IdeaShellCommandString, ShellDetailed)) { s =>
    val userPrompt = s.get(BasicKeys.shellPrompt) match {
      case Some(pf) => pf(s)
      case None => "> "
    }
    val prompt = IdeaPromptMarker + userPrompt

    // Do not pass the history file to avoid cluttering sbt's default command history
    // and because it's unnecessary - the IDEA shell (AbstractConsoleRunnerWithHistory) provides its own history mechanism.
    val reader = FullReaderCompat.newFullReader(history = None, s)
    val line = reader.readLine(prompt)
    line match {
      case Some(cmd) =>
        val newState = s.copy(
          onFailure = Some(IdeaShellExec),
          remainingCommands = Exec(cmd, s.source) +: IdeaShellExec +: s.remainingCommands
        ).setInteractive(true)
        if (cmd.trim.isEmpty) newState else newState.clearGlobalLog
      case None => s.setInteractive(false)
    }
  }