From a71305b4febc3d8db95d3d144ae3a64c023718f0 Mon Sep 17 00:00:00 2001 From: Kitson Kelly Date: Tue, 4 Jun 2019 23:03:56 +1000 Subject: Handle compiler diagnostics in Rust (#2445) --- cli/ansi.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'cli/ansi.rs') diff --git a/cli/ansi.rs b/cli/ansi.rs index 95b5e0694..b9e9fe123 100644 --- a/cli/ansi.rs +++ b/cli/ansi.rs @@ -1,6 +1,8 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +use ansi_term::Color::Black; use ansi_term::Color::Fixed; use ansi_term::Color::Red; +use ansi_term::Color::White; use ansi_term::Style; use regex::Regex; use std::env; @@ -43,6 +45,14 @@ pub fn italic_bold(s: String) -> impl fmt::Display { style.paint(s) } +pub fn black_on_white(s: String) -> impl fmt::Display { + let mut style = Style::new(); + if use_color() { + style = style.on(White).fg(Black); + } + style.paint(s) +} + pub fn yellow(s: String) -> impl fmt::Display { let mut style = Style::new(); if use_color() { @@ -61,6 +71,22 @@ pub fn cyan(s: String) -> impl fmt::Display { style.paint(s) } +pub fn red(s: String) -> impl fmt::Display { + let mut style = Style::new(); + if use_color() { + style = style.fg(Red); + } + style.paint(s) +} + +pub fn grey(s: String) -> impl fmt::Display { + let mut style = Style::new(); + if use_color() { + style = style.fg(Fixed(8)); + } + style.paint(s) +} + pub fn bold(s: String) -> impl fmt::Display { let mut style = Style::new(); if use_color() { -- cgit v1.2.3