@@ -20,9 +20,12 @@ import com.beust.jcommander.MissingCommandException
2020import com.beust.jcommander.ParameterException
2121import com.google.common.eventbus.EventBus
2222import com.haulmont.cuba.cli.commands.*
23+ import com.haulmont.cuba.cli.cubaplugin.model.ProjectModel
24+ import com.haulmont.cuba.cli.cubaplugin.model.ProjectStructure
2325import com.haulmont.cuba.cli.event.AfterCommandExecutionEvent
2426import com.haulmont.cuba.cli.event.BeforeCommandExecutionEvent
2527import com.haulmont.cuba.cli.event.ErrorEvent
28+ import org.fusesource.jansi.Ansi
2629import org.jline.builtins.Completers
2730import org.jline.builtins.Completers.TreeCompleter.Node
2831import org.jline.builtins.Completers.TreeCompleter.node
@@ -82,7 +85,7 @@ class ShellCli(private val commandsRegistry: CommandsRegistry) : Cli {
8285
8386 (lineReader as ? LineReaderImpl )?.completer = createCommandsCompleter(commandsRegistry)
8487
85- val line = lineReader.readLine(PROMPT ).also {
88+ val line = lineReader.readLine(buildPrompt() ).also {
8689 it != null || return
8790 }.takeIf {
8891 it.isNotBlank()
@@ -117,6 +120,15 @@ class ShellCli(private val commandsRegistry: CommandsRegistry) : Cli {
117120 }
118121 }
119122
123+ private fun buildPrompt (): String = try {
124+ val projectNameGreen = Ansi .ansi()
125+ .fgGreen().render(ProjectModel (ProjectStructure ()).name).fgDefault()
126+ .toString()
127+ " ($projectNameGreen ) $PROMPT "
128+ } catch (e: Exception ) {
129+ PROMPT
130+ }
131+
120132 private fun evalCommand (command : CliCommand ) {
121133 bus.post(BeforeCommandExecutionEvent (command))
122134 try {
0 commit comments