module Console::Output::Default
def self.github_actions?(env = ENV)
Detect if we're running in GitHub Actions, where human-readable output is preferred.
def self.github_actions?(env = ENV) env["GITHUB_ACTIONS"] == "true" end
def self.mail?(env = ENV)
Detect if we're running in a cron job or mail context where human-readable output is preferred.
def self.mail?(env = ENV) env.key?("MAILTO") && !env["MAILTO"].empty? end
def self.new(stream, env: ENV, **options)
@parameter options [Hash] Additional options to customize the output.
@parameter env [Hash] Environment variables (defaults to ENV for testing).
@parameter io [IO] The output stream.
Create a new output format based on the given stream.
def self.new(stream, env: ENV, **options) stream ||= $stderr if stream.tty? output = Terminal.new(stream, **options) elsif self.mail?(env) output = Text.new(stream, **options) elsif self.github_actions?(env) output = XTerm.new(stream, **options) else output = Serialized.new(stream, **options) end return output end