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

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

#583 in Command-line interface

Download history 3203/week @ 2023-12-17 2540/week @ 2023-12-24 2546/week @ 2023-12-31 3263/week @ 2024-01-07 3124/week @ 2024-01-14 2924/week @ 2024-01-21 2998/week @ 2024-01-28 2672/week @ 2024-02-04 2570/week @ 2024-02-11 2611/week @ 2024-02-18 2801/week @ 2024-02-25 2945/week @ 2024-03-03 2914/week @ 2024-03-10 2778/week @ 2024-03-17 3081/week @ 2024-03-24 3423/week @ 2024-03-31

12,540 downloads per month
Used in 138 crates (26 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

~245–560KB