autoDetermine whether stderr is a terminal or not automatically.
offAssume stderr is not a terminal.
onAssume stderr is a terminal.
pub fn renderOptions(color: Color) std.zig.ErrorBundle.RenderOptionscolor: Colorpub fn renderOptions(color: Color) std.zig.ErrorBundle.RenderOptions {
return .{
.ttyconf = get_tty_conf(color),
};
}pub const Color = enum {
/// Determine whether stderr is a terminal or not automatically.
auto,
/// Assume stderr is not a terminal.
off,
/// Assume stderr is a terminal.
on,
pub fn get_tty_conf(color: Color) std.io.tty.Config {
return switch (color) {
.auto => std.io.tty.detectConfig(std.io.getStdErr()),
.on => .escape_codes,
.off => .no_color,
};
}
pub fn renderOptions(color: Color) std.zig.ErrorBundle.RenderOptions {
return .{
.ttyconf = get_tty_conf(color),
};
}
}