1use colored::Colorize;
4use std::io::IsTerminal;
5
6fn color_enabled() -> bool {
7 std::io::stdout().is_terminal()
8 && crate::git::Git::color_output()
9}
10
11pub fn label(s: &str) -> String {
12 if color_enabled() {
13 s.cyan().bold().to_string()
14 } else {
15 s.to_string()
16 }
17}
18
19pub fn success(s: &str) -> String {
20 if color_enabled() {
21 s.green().to_string()
22 } else {
23 s.to_string()
24 }
25}
26
27pub fn error(s: &str) -> String {
28 if color_enabled() {
29 s.red().to_string()
30 } else {
31 s.to_string()
32 }
33}
34
35pub fn dim(s: &str) -> String {
36 if color_enabled() {
37 s.dimmed().to_string()
38 } else {
39 s.to_string()
40 }
41}