-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #6.
- Loading branch information
Showing
3 changed files
with
92 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::cli::ColorChoice; | ||
|
||
/// Resets all colors and styles. | ||
const RESET: &str = "\x1b[0m"; | ||
|
||
/// Bold. | ||
const BOLD: &str = "\x1b[1m"; | ||
|
||
/// Dim. | ||
const DIM: &str = "\x1b[2m"; | ||
|
||
/// Info (cyan). | ||
const INFO: &str = "\x1b[36m"; | ||
|
||
/// Success (green). | ||
const SUCCESS: &str = "\x1b[32m"; | ||
|
||
/// Error (magenta). | ||
const ERROR: &str = "\x1b[35m"; | ||
|
||
pub struct Color { | ||
pub reset: &'static str, | ||
pub bold: &'static str, | ||
pub dim: &'static str, | ||
pub info: &'static str, | ||
pub success: &'static str, | ||
pub error: &'static str, | ||
} | ||
|
||
impl Color { | ||
pub fn from_color_choice(choice: ColorChoice) -> Self { | ||
match choice { | ||
ColorChoice::Always => Color { | ||
reset: RESET, | ||
bold: BOLD, | ||
dim: DIM, | ||
info: INFO, | ||
success: SUCCESS, | ||
error: ERROR, | ||
}, | ||
ColorChoice::Never => Color { | ||
reset: "", | ||
bold: "", | ||
dim: "", | ||
info: "", | ||
success: "", | ||
error: "", | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters