#terminal-colors #ansi-term #terminal #ansi #ansi-colors #color #console

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

#1103 in Command-line interface

Download history 3143/week @ 2024-07-21 3445/week @ 2024-07-28 2928/week @ 2024-08-04 4937/week @ 2024-08-11 4710/week @ 2024-08-18 5730/week @ 2024-08-25 5905/week @ 2024-09-01 5829/week @ 2024-09-08 4777/week @ 2024-09-15 3873/week @ 2024-09-22 3063/week @ 2024-09-29 2523/week @ 2024-10-06 2885/week @ 2024-10-13 2967/week @ 2024-10-20 2194/week @ 2024-10-27 1432/week @ 2024-11-03

9,728 downloads per month
Used in 118 crates (24 directly)

MIT license

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