From 33a8fed19239207b5b342484a7ccd9a8b1f67734 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 9 Jan 2025 23:18:33 +0100 Subject: [PATCH] refactor --- src/config.rs | 2 +- src/install/bluetooth.rs | 3 ++- src/install/mod.rs | 6 +++--- src/print.rs | 18 +++++++++++------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/config.rs b/src/config.rs index e6dffa1..1375cd8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -86,7 +86,7 @@ pub struct GeneralConfig { // Root password pub root_password: Option, // Enable Bluetooth - pub bluetooth: Option + pub bluetooth: Option, } #[derive(Debug, Clone, Deserialize)] diff --git a/src/install/bluetooth.rs b/src/install/bluetooth.rs index 58d1ead..689688d 100644 --- a/src/install/bluetooth.rs +++ b/src/install/bluetooth.rs @@ -1,7 +1,8 @@ -use crate::{linux::systemd_service_enable, pkg::install_pkgs}; +use crate::{linux::systemd_service_enable, pkg::install_pkgs, print_status}; /// Enable Bluetooth pub fn setup_bluetooth() { + print_status("Setting up Bluetooth"); install_pkgs(&["bluez", "bluez-utils"]); systemd_service_enable("bluetooth.service"); } diff --git a/src/install/mod.rs b/src/install/mod.rs index bd785a2..3bc7d0b 100644 --- a/src/install/mod.rs +++ b/src/install/mod.rs @@ -20,6 +20,7 @@ use virt::setup_virtualization; use yansi::{Color, Paint}; use zram::setup_zram; +pub mod bluetooth; pub mod boot; pub mod desktop; pub mod docker; @@ -34,7 +35,6 @@ pub mod ssh; pub mod user; pub mod virt; pub mod zram; -pub mod bluetooth; use crate::{ config::InstallConfig, @@ -132,11 +132,11 @@ pub fn install(conf: InstallConfig) { } setup_zram(); - + if conf.general.bluetooth.unwrap_or_default() { setup_bluetooth(); } - + setup_mkinitcpio(&conf.drive); setup_secure_boot(); diff --git a/src/print.rs b/src/print.rs index 24cf4e1..cd77dde 100644 --- a/src/print.rs +++ b/src/print.rs @@ -58,11 +58,10 @@ pub fn print_config(conf: &InstallConfig) { conf.general.timezone )); if conf.general.root_password.is_some() { - general_info.add_str(format!( - "🔑 {} {}", - "Root Password".paint(Color::Yellow), - "✔️".paint(Color::Green) - )); + general_info.add_str(format!("🔑 Root Password {}", "✔️".paint(Color::Green))); + } + if conf.general.bluetooth.unwrap_or_default() { + general_info.add_str(format!("🌀 Bluetooth {}", "✔️".paint(Color::Green))); } root_info.add_tree("🔨 General", general_info); @@ -79,7 +78,8 @@ pub fn print_config(conf: &InstallConfig) { if !conf.pkg.pkg.is_empty() { pkg_info.add_str(format!( - "📦 Additional packages: {}", + "📦 {} {}", + "Additional packages:".paint(Color::Yellow), conf.pkg.pkg.join(" ") )); } @@ -145,7 +145,11 @@ pub fn print_config(conf: &InstallConfig) { } if let Some(models) = &ai_conf.models { - ai_info.add_str(format!("⬇️ Pull Models: {}", models.join(", "))); + ai_info.add_str(format!( + "⬇️ {} {}", + "Pull Models:".paint(Color::Yellow), + models.join(", ") + )); } root_info.add_tree("🦙 Ollama", ai_info);