| Crates.io | colored-macro |
| lib.rs | colored-macro |
| version | 0.2.0 |
| created_at | 2023-04-19 12:03:13.022188+00 |
| updated_at | 2023-05-15 10:00:16.493291+00 |
| description | A macro to make colored text in the terminal using XML-like syntax |
| homepage | |
| repository | https://github.com/Jamalam360/colored-macro |
| max_upload_size | |
| id | 843494 |
| size | 6,871 |
Colored macro is a Rust crate for creating colored and formatted strings using ANSI codes in a readable way. It uses XML-like syntax:
<red>red text</red> <bold>bold text</bold> <green>{fmt_expr}</green>
With current crates, messages quickly become hard to quickly understand at a glance. This is best explained with an example:
println!("[{}] ({}): {}", level.green(), timestamp.blue(), message.bold());
You can see that even with a simple message, the format string becomes hard to quickly understand, compared to the equivalent using this crate:
println!("{}", colored!("[<green>{level}</green>] (<blue>{timestamp}</blue>): <bold>{message}</bold>"));
The following styles are available:
rgb(10, 12, 200), #0012G4).reset (resets current styles)bolddimitalicunderlineblinkreversehiddenstrikethroughStyles can also be nested:
colored_macro::colored!("<red>all red <yellow>yellow <blue>now to blue</blue> back to yellow</yellow> back to red</red>")
NO_COLOR SupportThe NO_COLOR environment variable is supported if the no-color feature is enabled.
