8 releases (5 breaking)

0.6.0 Mar 15, 2021
0.5.0 Mar 18, 2020
0.4.0 Feb 25, 2020
0.3.1 Feb 25, 2020
0.1.0 Apr 9, 2017

#89 in Command-line interface

Download history 256/week @ 2021-06-30 238/week @ 2021-07-07 211/week @ 2021-07-14 300/week @ 2021-07-21 337/week @ 2021-07-28 442/week @ 2021-08-04 359/week @ 2021-08-11 204/week @ 2021-08-18 262/week @ 2021-08-25 376/week @ 2021-09-01 737/week @ 2021-09-08 759/week @ 2021-09-15 446/week @ 2021-09-22 443/week @ 2021-09-29 547/week @ 2021-10-06 501/week @ 2021-10-13

2,453 downloads per month
Used in less than 13 crates

MIT/Apache

36KB
753 lines

Colour

Macros for creating coloured console output.

General

The following macros are provided:

Colour Dark Variant With LF Dark With LF
black! dark_black! black_ln! dark_black_ln!
red! dark_red! red_ln! dark_red_ln!
green! dark_green! green_ln! dark_green_ln!
yellow! dark_yellow! yellow_ln! dark_yellow_ln!
blue! dark_blue! blue_ln! dark_blue_ln!
magenta! dark_magenta! magenta_ln! dark_magenta_ln!
cyan! dark_cyan! cyan_ln! dark_cyan_ln!
white! dark_white! white_ln! dark_white_ln!

The versions with suffix _ln append a newline (similar to print! versus println!).

There are also prnt! and prnt_ln! available which print using the current default foreground colour.

Example

#[macro_use]
extern crate colour;

fn foo() {
    let err: Result<(), u8> = Err(1);
    prnt_ln!("Failed on {}", 9);
    yellow!("Error details: ");
    red_ln!("{:?}", err);
}

fn all_colours() {
    black!("black ");
    red!("red ");
    green!("green ");
    yellow!("yellow ");
    blue!("blue ");
    magenta!("magenta ");
    cyan!("cyan ");
    white!("white ");
    dark_black!("dark_black ");
    dark_red!("dark_red ");
    dark_green!("dark_green ");
    dark_yellow!("dark_yellow ");
    dark_blue!("dark_blue ");
    dark_magenta!("dark_magenta ");
    dark_cyan!("dark_cyan ");
    dark_white!("dark_white ");
    prnt!("default colour\n\n");
}

License

colour is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-MIT and LICENSE-APACHE for details.

Dependencies

~0.7–1MB
~21K SLoC