https://github.com/cuppachino/farve
Tiny macros for owo-color'ful logging and printing.
https://github.com/cuppachino/farve
cli color logging rust-lang
Last synced: 5 months ago
JSON representation
Tiny macros for owo-color'ful logging and printing.
- Host: GitHub
- URL: https://github.com/cuppachino/farve
- Owner: cuppachino
- Created: 2023-03-07T21:57:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T04:11:07.000Z (over 3 years ago)
- Last Synced: 2025-09-28T05:58:40.020Z (9 months ago)
- Topics: cli, color, logging, rust-lang
- Language: Rust
- Homepage: https://docs.rs/crate/farve/latest
- Size: 55.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Farve
🔗[docs.rs](https://docs.rs/crate/farve/latest)
🔗[crates.io](https://crates.io/crates/farve)
A bite-sized *`macro_rules!`* wrapper around [`owo-colors`](https://github.com/jam1garner/owo-colors) for public-facing CLI applications.
```rust
use owo_colors::OwoColorize;
use farve::{efarve, farve};
//stdout
farve!(silly, "silly 😋".white().bold(), 2);
farve!(debug, '🐛', 0);
farve!(info, "info".blue(), 1);
// stderr
efarve!(warn, "WARN".bright_yellow(), 2);
efarve!(error, "ERROR".bright_red().underline(), 0);
fn main() {
silly("Hello, world!");
debug("We're gonna need a bigger net...");
info("The weather is nice today.");
warn("I almost couldn't, but I did it!");
error("Something went so wrong!");
}
```

## Usage
Add `farve` to your `Cargo.toml`:
```apache
cargo add farve
```
## `farve!` and `efarve!`
```rust
use owo_colors::OwoColorize;
use farve::{efarve, farve};
farve!(info);
efarve!(warn, "warning".bright_yellow());
fn main() {
info("Hello cargo!");
warn("I almost forgot to show you the brackets 👇");
}
```

## `brackets`
The final parameter can be used to change the brightness of the brackets.
```rust
use farve::{brackets, farve};
fn main() {
/// -> [default]
println!("{}", brackets!("default"));
/// -> [darkest]
println!("{}", brackets!("darkest", 0));
/// -> [gray]
println!("{}", brackets!("gray", 1));
/// -> [brightest]
println!("{}", brackets!("brightest", 2));
}
```

## `brackets!` can be used through `farve!` and `efarve!`
```rust
use farve::{farve, efarve};
farve!(spooky,"spooky🎃".red(), 0);
farve!(silly, "silly🤪".white().italic(), 2);
```