#ansi #windows #console #terminal #color

fwdansi

Forwards a byte string with ANSI escape code to a termcolor terminal

2 stable releases

Uses old Rust 2015

1.1.0 Nov 17, 2019
1.0.1 Jul 31, 2018

#106 in Command-line interface

Download history 4893/week @ 2021-04-03 4446/week @ 2021-04-10 4540/week @ 2021-04-17 5126/week @ 2021-04-24 4982/week @ 2021-05-01 4257/week @ 2021-05-08 4273/week @ 2021-05-15 3664/week @ 2021-05-22 4188/week @ 2021-05-29 4144/week @ 2021-06-05 3969/week @ 2021-06-12 5072/week @ 2021-06-19 4240/week @ 2021-06-26 4326/week @ 2021-07-03 5106/week @ 2021-07-10 3785/week @ 2021-07-17

20,318 downloads per month
Used in 93 crates (13 directly)

MIT license

9KB
190 lines


lib.rs:

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

~205–295KB