allow colored welcome in docker
@@ -2,7 +2,15 @@ use std::env;
use api::grpc::models::VersionInfo;
use atty::Stream;
-use colored::Colorize;
+use colored::{Color, ColoredString, Colorize};
+
+fn paint(text: &str, true_color: bool) -> ColoredString {
+ if true_color {
+ text.bold().truecolor(184, 20, 56)
+ } else {
+ text.bold().color(Color::Red)
+ }
+}
/// Prints welcome message
#[rustfmt::skip]
@@ -11,19 +19,21 @@ pub fn welcome() {
colored::control::set_override(false);
}
+ let mut true_color = true;
+
match env::var("COLORTERM") {
Ok(val) => if val != "24bit" && val != "truecolor" {
- colored::control::set_override(false);
+ true_color = false;
},
- Err(_) => colored::control::set_override(false),
+ Err(_) => true_color = false,
}
- println!("{}", r#" _ _ "#.bold().truecolor(184, 20, 56));
- println!("{}", r#" __ _ __| |_ __ __ _ _ __ | |_ "#.bold().truecolor(184, 20, 56));
- println!("{}", r#" / _` |/ _` | '__/ _` | '_ \| __| "#.bold().truecolor(184, 20, 56));
- println!("{}", r#"| (_| | (_| | | | (_| | | | | |_ "#.bold().truecolor(184, 20, 56));
- println!("{}", r#" \__, |\__,_|_| \__,_|_| |_|\__| "#.bold().truecolor(184, 20, 56));
- println!("{}", r#" |_| "#.bold().truecolor(184, 20, 56));
+ println!("{}", paint(r#" _ _ "#, true_color));
+ println!("{}", paint(r#" __ _ __| |_ __ __ _ _ __ | |_ "#, true_color));
+ println!("{}", paint(r#" / _` |/ _` | '__/ _` | '_ \| __| "#, true_color));
+ println!("{}", paint(r#"| (_| | (_| | | | (_| | | | | |_ "#, true_color));
+ println!("{}", paint(r#" \__, |\__,_|_| \__,_|_| |_|\__| "#, true_color));
+ println!("{}", paint(r#" |_| "#, true_color));
println!();
let ui_link = format!("https://ui.qdrant.tech/?v=v{}", VersionInfo::default().version);
