2 stable releases
Uses old Rust 2015
1.1.0 | Nov 17, 2019 |
---|---|
1.0.1 | Jul 31, 2018 |
#1103 in Command-line interface
9,728 downloads per month
Used in 118 crates
(24 directly)
9KB
190 lines
Write colored strings with ANSI escape code into a termcolor
terminal.
This package provides a single function, write_ansi
, which parses ANSI
escape codes in the provided byte string and transforms them into the
corresponding termcolor
commands. The colors will be supported even on a
Windows console.
The main purpose of this package is to forward colored output from a child process.
extern crate termcolor;
extern crate fwdansi;
use termcolor::*;
use std::io;
use std::process::Command;
use fwdansi::write_ansi;
fn main() -> io::Result<()> {
let output = Command::new("rustc").args(&["--color", "always"]).output()?;
let mut stderr = StandardStream::stderr(ColorChoice::Always);
write_ansi(&mut stderr, &output.stderr)?;
//^ should print "error: no input filename given" with appropriate color everywhere.
Ok(())
}
Dependencies
~0.2–6.5MB
~42K SLoC