summaryrefslogtreecommitdiff
path: root/cli/ansi.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2019-06-04 23:03:56 +1000
committerRyan Dahl <ry@tinyclouds.org>2019-06-04 09:03:56 -0400
commita71305b4febc3d8db95d3d144ae3a64c023718f0 (patch)
treef0dcc6017f62380b02a08d800503fbf7242fbe72 /cli/ansi.rs
parent60d452264198adb3da4820236cf8ea35d33486cd (diff)
Handle compiler diagnostics in Rust (#2445)
Diffstat (limited to 'cli/ansi.rs')
-rw-r--r--cli/ansi.rs26
1 files changed, 26 insertions, 0 deletions
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() {