axl_lib/config/
constants.rs1use colored::{Colorize, CustomColor};
2use rand::Rng;
3use serde_derive::{Deserialize, Serialize};
4use strum::IntoEnumIterator;
5use strum_macros::EnumIter;
6
7pub const HOME_DIR_KEY: &str = "HOME";
8pub const XDG_CONFIG_HOME_DIR_KEY: &str = "XDG_CONFIG_HOME";
9pub const XDG_DATA_HOME_DIR_KEY: &str = "XDG_DATA_HOME";
10pub const XDG_STATE_HOME_DIR_KEY: &str = "XDG_STATE_HOME";
11pub const DEFAULT_MULTIPLEXER_KEY: &str = "AXL_DEFAULT_MULTIPLEXER";
12pub const DEFAULT_PROJECTS_CONFIG_PATH_KEY: &str = "AXL_PROJECTS_CONFIG_PATH";
13
14pub const PROJ_NAME: &str = env!("CARGO_PKG_NAME");
16pub const OS_PLATFORM: &str = std::env::consts::OS;
17pub const AXL_VERSION_STR: &str = version_str();
18pub const AXL_GIT_SHA_LONG: &str = env!("GIT_SHA_LONG");
19pub const AXL_GIT_SHA_SHORT: &str = env!("GIT_SHA_SHORT");
20
21pub const fn version_str() -> &'static str {
22 if option_env!("GIT_SHA_SHORT").is_some() && !env!("GIT_SHA_SHORT").is_empty() {
23 concat!(env!("CARGO_PKG_VERSION"), "-dev-", env!("GIT_SHA_SHORT"))
24 } else {
25 env!("CARGO_PKG_VERSION")
26 }
27}
28
29pub fn print_version_string(show_art: bool) {
30 eprintln!(
31 "{} {}{}{} {} {} {}\n{}",
32 "~=".custom_color(AxlColor::HotPink.into()),
33 PROJ_NAME.custom_color(AxlColor::TiffanyBlue.into()),
34 "@".custom_color(AxlColor::HotPink.into()),
35 AXL_VERSION_STR.custom_color(AxlColor::TiffanyBlue.into()),
36 "on".custom_color(AxlColor::HotPink.into()),
37 OS_PLATFORM.custom_color(AxlColor::TiffanyBlue.into()),
38 "=~".custom_color(AxlColor::HotPink.into()),
39 if show_art {
40 let mut colors = AxlColor::iter();
41 let rand_color_index = rand::thread_rng().gen_range(0..colors.len());
42 let rand_art_index = rand::thread_rng().gen_range(0..ASCII_ART.len());
43 ASCII_ART[rand_art_index].to_string().custom_color(
44 colors
45 .nth(rand_color_index)
46 .unwrap_or(AxlColor::TiffanyBlue)
47 .into(),
48 )
49 } else {
50 "".normal()
51 },
52 );
53}
54
55#[derive(Debug, Serialize, Deserialize)]
56pub struct CliInfo<'a> {
57 pub version: &'a str,
58 pub commit: &'a str,
59 pub os_platform: &'a str,
60}
61
62#[derive(EnumIter)]
63pub enum AxlColor {
64 HotPink,
65 TiffanyBlue,
66 Mint,
67 Yellow,
68}
69
70impl From<AxlColor> for CustomColor {
71 fn from(axl_color: AxlColor) -> Self {
72 match axl_color {
73 AxlColor::HotPink => Self {
74 r: 255,
75 g: 174,
76 b: 188,
77 },
78 AxlColor::TiffanyBlue => Self {
79 r: 160,
80 g: 231,
81 b: 229,
82 },
83 AxlColor::Mint => Self {
84 r: 180,
85 g: 248,
86 b: 200,
87 },
88 AxlColor::Yellow => Self {
89 r: 251,
90 g: 231,
91 b: 198,
92 },
93 }
94 }
95}
96
97pub const ASCII_ART: [&str; 2] = [
98 "⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
99⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡏⠈⢱⠀⠀⡖⠲⣀⠀⠀⠀⠀⠀⠀⠀⠀
100⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠋⠹⡇⠀⡸⢠⠞⠳⠆⠈⡆⠀⠀⠀⠀⠀⠀⠀
101⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⠤⠤⠤⠤⠤⢬⣇⢀⣿⣚⢳⡏⠀⢰⠃⡴⠛⢦⠀⠀⠀⠀⠀⠀
102⠀⡠⣄⢠⠒⣄⠐⢄⠀⠀⣠⠴⠋⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⣿⣸⡟⢣⣠⣿⣯⣤⡔⠃⠀⠀⠀⠀⠀⠀
103⠘⣇⠈⢻⡀⠸⡄⠈⣆⠞⠁⠀⠀⠀⠀⠀⠀⠀⣶⣶⣄⡀⠀⠙⠿⣿⣿⣻⡿⠋⢹⠟⠉⡗⠂⠀⠀⠀⠀
104⢴⠚⠢⢤⣿⣧⣽⣶⣏⡀⠀⠀⠀⠀⠀⠀⣀⠀⠘⠿⡭⢯⠆⠐⢲⣿⣾⣿⢁⣶⣏⡠⠞⢳⠉⢩⠏⠀⠀
105⠈⡗⠒⣿⡈⣿⡍⣿⣿⣷⠀⣀⣴⣻⣶⠋⠉⠀⠀⠀⠀⠀⠀⠀⠀⢠⡾⠻⠿⣍⠉⣴⠒⠋⢀⠇⠀⠆⠀
106⢠⠽⠦⠈⣳⣌⣷⣿⠷⠟⠀⠀⠀⠀⠀⠀⠀⠀⣠⢶⡶⢤⣀⠀⢀⡼⠙⣶⣤⠟⠓⠋⠀⠀⠸⡀⠀⢦⠀
107⠘⠂⣤⡔⠛⢯⣙⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⡃⠀⠈⠙⠛⠓⠒⠛⠦⣀⠀⠀⠀⠀⠀⣇⠀⠘⡀
108⠀⠸⢅⣙⠶⢲⠟⠻⢿⡷⣄⣀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠂⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⣳⠀⢀⡏⠀⢠⠇
109⠀⠀⠀⠈⠀⠸⠤⠚⠛⠁⢾⠋⠉⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣴⢛⣉⠴⠛⠀⢀⡞⠀
110⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠒⠒⠦⠴⠦⠶⢤⣀⠀⠀⠀⠀⠀⠀⠀⢠⠿⣍⡉⠁⠀⠀⣀⡤⠊⠀⠀
111⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠲⠦⣄⣀⣀⡤⠴⠒⠚⠋⠉⠉⠉⠁⠀⠀⠀⠀",
112 "⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⣀⣀⡤⠤⠤⠤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
113⠀⠀⢴⠋⠙⠳⣤⡀⣠⠖⠋⠁⠀⠀⠀⠀⠀⠀⠀⠉⠓⠤⡀⣠⡴⠟⠛⣷⠀⠀
114⠀⠀⠈⠳⢤⣀⢈⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢏⣀⣠⡴⠋⠀⠀
115⢀⣠⣤⣄⣄⣉⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣇⣡⣤⡴⣦⣀
116⢹⣅⡀⠀⠀⠈⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡏⠁⠀⢀⣠⠏
117⠀⠈⠙⠉⢋⣉⣇⠀⠀⣾⣷⠄⠀⠀⠀⠀⠀⠀⠀⢴⣿⡆⠀⢀⣿⡙⠋⠋⠀⠀
118⠀⠀⢤⠶⠋⠉⢈⣦⡀⠈⠉⠀⠀⠀⠉⠉⠉⠀⠀⠀⠉⠀⣠⣎⠈⠉⠛⢷⡀⠀
119⠀⠀⠻⣤⣤⠶⠋⠀⠈⠑⠠⠄⣀⣀⣀⣀⣀⣀⡀⠤⠐⠉⠀⠈⠻⠶⠖⠶⠃⠀
120⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠃⠤⡀⠀⡠⠤⢱⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
121⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠉⠁⠀⠉⠉⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
122⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢀⠤⡀⠀⡠⢄⢀⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
123⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠢⣀⣀⣀⣈⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
124⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡌⡇⠀⣎⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
125⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢡⡇⣸⠜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
126⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠓⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀",
127];