Skip to main content
Glama
ProgressBar.kt1.03 kB
package maestro.cli.view import maestro.cli.DisableAnsiMixin import org.fusesource.jansi.Ansi class ProgressBar(private val width: Int) { private var progressWidth: Int? = null private var alreadyPrinted = 0 fun set(progress: Float) { if (DisableAnsiMixin.ansiEnabled) { val progressWidth = (progress * width).toInt() if (progressWidth == this.progressWidth) return this.progressWidth = progressWidth val ansi = Ansi.ansi() ansi.cursorToColumn(0) ansi.fgCyan() repeat(progressWidth) { ansi.a("█") } repeat(width - progressWidth) { ansi.a("░") } ansi.fgDefault() System.err.print(ansi) } else { val progressFactor = (progress * width).toInt() var amountToAdd = progressFactor - alreadyPrinted if (amountToAdd < 0) amountToAdd = 0 alreadyPrinted = progressFactor print(".".repeat(amountToAdd)) } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mobile-dev-inc/Maestro'

If you have feedback or need assistance with the MCP directory API, please join our Discord server