A Rust library to build messages for cli tools with NerdFonts or Unicode icons.
Table of Contents
There is only a Whisper struct and an IconKind enum.
use murmur::{Whisper, IconKind};The IconKind enum variants map to a specific Unicode or NerdFont icon, each icon has a default color.
Casing conforms to Rust API Guidelines.
NfFaTimesNfFaCheckNfFaInfoCircleNfFaRefreshNfFaWarningNfFaBugUnicodeCrossMarkUnicodeCheckMarkUnicodeInformationSourceUnicodeGearUnicodeWarningSignUnicodeBug
For a full list of the currently supported icons, see the IconKind enum.
use murmur::{Whisper, IconKind};
use owo_colors::OwoColorize;
Whisper::new()
.icon(IconKind::NfFaCheck)
.message("message")
.message("message".red())
.whisper()
.unwrap();
The Whisper struct provides the following methods:
new(): Creates a newWhisperinstance.icon(): Adds an icon to theWhisperinstance.message(): Adds a message to theWhisperinstance.messages(): Adds multiple messages to theWhisperinstance.whisper(): Builds theWhisperinstance and prints the messages
Here are some examples of how to use the Whisper struct.
use murmur::{Whisper, IconKind};
Whisper::new()
.icon(IconKind::NfFaCheck)
.message("message")
.whisper()
.ok();use murmur::{Whisper, IconKind};
Whisper::new().icon(IconKind::UnicodeCheckMark).whisper().ok();use murmur::Whisper;
use std::io::{Error, ErrorKind};
fn main() -> Result<(), Error> {
Whisper::new()
.message("1 message")
.message("2 message")
.message("3 message")
.whisper()
.map_err(|err| Error::new(ErrorKind::Other, err))?;
Ok(())
}Output:
1 message without icon
2 message without icon indents by 2 spaces all messages after the first
3 message
use murmur::Whisper;
Whisper::new()
.messages(["1 message without icon", "2 message", "3 message"])
.whisper()
.ok();
Whisper::new()
.messages(vec!["1 message without icon", "2 message", "3 message"])
.whisper()
.ok();The whisper method returns -> Result<(), WhisperError>
use murmur::{Whisper, IconKind, WhisperError};
use std::io::{Error, ErrorKind};
fn whisper_new() -> Result<(), WhisperError> {
let whisper = Whisper::new()
.icon(IconKind::NfFaBug)
.message("The `whisper` method returns `-> Result<(), WhisperError>`")
.whisper()?;
Ok(())
}