added readme

This commit is contained in:
wpbirney 2022-06-02 13:50:42 -04:00
parent 586249d95f
commit fc746a613d
2 changed files with 16 additions and 0 deletions

14
readme.md Normal file
View File

@ -0,0 +1,14 @@
# mirc-rs
A simple mirc color code formatter partially inspired by [yansi](https://github.com/SergioBenitez/yansi)
## Usage
```rust
use mirc::Color;
irc.send_privmsg("#channel", Color::red("red text"));
irc.send_privmsg("#channel", format!("Hello: {}", Color::blue("nick")));
```
Works on any type that impl's fmt::Display

View File

@ -17,6 +17,7 @@ pub enum ColorCode {
Pink,
Grey,
LightGrey,
Raw(i32),
Unset,
}
@ -39,6 +40,7 @@ impl fmt::Display for ColorCode {
ColorCode::Pink => write!(f, "13"),
ColorCode::Grey => write!(f, "14"),
ColorCode::LightGrey => write!(f, "15"),
ColorCode::Raw(c) => write!(f, "{:02}", c),
ColorCode::Unset => Ok(()),
}
}