From 896121ab0d06a82d81222b33463e9156fe0cf1f6 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Mon, 22 Apr 2024 13:00:55 +0200 Subject: [PATCH] Add example usage doc to label enum --- crates/lune-utils/src/fmt/label.rs | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/crates/lune-utils/src/fmt/label.rs b/crates/lune-utils/src/fmt/label.rs index aa5d84a..5e2e290 100644 --- a/crates/lune-utils/src/fmt/label.rs +++ b/crates/lune-utils/src/fmt/label.rs @@ -2,6 +2,24 @@ use std::fmt; use console::{style, Color}; +/** + Label enum used for consistent output formatting throughout Lune. + + # Example usage + + ```rs + use lune_utils::fmt::Label; + + println!("{} This is an info message", Label::Info); + // [INFO] This is an info message + + println!("{} This is a warning message", Label::Warn); + // [WARN] This is a warning message + + println!("{} This is an error message", Label::Error); + // [ERROR] This is an error message + ``` +*/ #[derive(Debug, Clone, Copy)] pub enum Label { Info, @@ -11,14 +29,14 @@ pub enum Label { impl Label { /** - Returns the name of the label in lowercase. + Returns the name of the label in all uppercase. */ #[must_use] pub fn name(&self) -> &str { match self { - Self::Info => "info", - Self::Warn => "warn", - Self::Error => "error", + Self::Info => "INFO", + Self::Warn => "WARN", + Self::Error => "ERROR", } } @@ -41,7 +59,7 @@ impl fmt::Display for Label { f, "{}{}{}", style("[").dim(), - style(self.name().to_ascii_uppercase()).fg(self.color()), + style(self.name()).fg(self.color()), style("]").dim() ) }