Skip to main content
Glama
DisableAnsiMixin.kt1.99 kB
package maestro.cli import org.fusesource.jansi.Ansi import org.fusesource.jansi.AnsiConsole import org.fusesource.jansi.internal.CLibrary import picocli.CommandLine class DisableAnsiMixin { @CommandLine.Option( names = ["--no-color", "--no-ansi"], negatable = true, description = ["Enable / disable colors and ansi output"] ) var enableANSIOutput = true companion object { var ansiEnabled = true private set fun executionStrategy(parseResult: CommandLine.ParseResult): Int { applyCLIMixin(parseResult) return CommandLine.RunLast().execute(parseResult) } private fun findFirstParserWithMatchedParamLabel(parseResult: CommandLine.ParseResult, paramLabel: String): CommandLine.ParseResult? { val found = parseResult.matchedOptions().find { it.paramLabel() == paramLabel } if (found != null) { return parseResult } parseResult.subcommands().forEach { return findFirstParserWithMatchedParamLabel(it, paramLabel) ?: return@forEach } return null } private fun applyCLIMixin(parseResult: CommandLine.ParseResult) { // Find the first mixin for which of the enable-ansi parameter was specified val parserWithANSIOption = findFirstParserWithMatchedParamLabel(parseResult, "<enableANSIOutput>") val mixin = parserWithANSIOption?.commandSpec()?.mixins()?.values?.firstNotNullOfOrNull { it.userObject() as? DisableAnsiMixin } val stdoutIsTTY = CLibrary.isatty(CLibrary.STDOUT_FILENO) != 0 ansiEnabled = mixin?.enableANSIOutput // Use the param value if it was specified ?: stdoutIsTTY // Otherwise fall back to checking if output is a tty Ansi.setEnabled(ansiEnabled) if (ansiEnabled) { AnsiConsole.systemInstall() } } } }

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