macro_rules! cformat {
($title:expr, $msg:expr => $color:ident) => { ... };
($title:expr, $msg:expr => ($r:expr, $g:expr, $b:expr)) => { ... };
($title:expr, $msg:expr) => { ... };
($msg:expr => $color:ident) => { ... };
($msg:expr => ($r:expr, $g:expr, $b:expr)) => { ... };
($msg:expr) => { ... };
}Expand description
Get a string of a message like Cargo does. If you pass only one string, the first word is the title and the rest is the message. If you pass two strings the first one is the title and the second one is the message.
You can specify the color of the title with a predefined color from the colored::Color enum or with RGB values (r, g, b). To specify the color use => after the strings.
The end of the title is padded with spaces to make it 12 characters long.
// Specifying the color with a predefined color
// ✅: You can put spaces in the title, so it can be something like "Cleaning up"
let string = cformat!("Cleaning up", "the mess" => Green);
let string = cformat!("Using", "cprint crate!" => Green);
// Specifying the color with RGB values
let string = cformat!("Using", "cprint crate!" => (255, 255, 0));
// Using the default color (Green)
let string = cformat!("Using", "cprint crate!");
// Using only one string. The first word is the title and the rest is the message.
// ⚠️: The title is the first word of the string, so it must not contain any spaces.
let string = cformat!("Compiling main.rs" => Green);
// Using only one string with RGB values
// ⚠️: The title is the first word of the string, so it must not contain any spaces.
let string = cformat!("Compiling main.rs" => (0, 255, 0));
// Using only one string with the default color (Green)
// ⚠️: The title is the first word of the string, so it must not contain any spaces.
let string = cformat!("Compiling main.rs");