This commit is contained in:
JMARyA 2024-12-28 01:19:44 +01:00
parent eabd898ccf
commit f2b1a43f62
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
13 changed files with 453 additions and 390 deletions

View file

@ -10,13 +10,18 @@ mod install;
mod pkg;
use create_iso::create_iso;
use install::install;
use yansi::{Color, Paint};
fn is_root() -> bool {
getuid() == Uid::from_raw(0)
}
fn run_command(cmd: &[String], input: Option<&str>, inherit: bool) -> (String, String) {
println!("--> {}", cmd.join(" "));
println!(
"{} {}",
"-->".paint(Color::Red),
cmd.join(" ").paint(Color::Blue.bold())
);
let mut cmd_setup = std::process::Command::new(cmd[0].clone());
let mut cmd_setup = cmd_setup.args(cmd.into_iter().skip(1).collect::<Vec<_>>());
@ -62,7 +67,11 @@ fn run_command(cmd: &[String], input: Option<&str>, inherit: bool) -> (String, S
}
fn main() {
println!("⚠️ Warning: This is an alpha version of the installer. DO NOT USE in PROD");
println!(
"{}",
"⚠️ Warning: This is an alpha version of the installer. DO NOT USE in PROD"
.paint(Color::Yellow)
);
let args = args::get_args();
@ -83,12 +92,16 @@ fn main() {
Ok(content) => match toml::from_str(&content) {
Ok(config) => config,
Err(e) => {
eprintln!("Error: Could not deserialize TOML file. {e}");
eprintln!(
"{} {}",
"Error: Could not deserialize TOML file.".paint(Color::Red),
e.paint(Color::Red)
);
std::process::exit(1);
}
},
Err(_) => {
eprintln!("Error: Could not read config file.");
eprintln!("{}", "Error: Could not read config file.".paint(Color::Red));
std::process::exit(1);
}
};
@ -104,19 +117,23 @@ fn main() {
Ok(content) => match toml::from_str(&content) {
Ok(config) => config,
Err(e) => {
eprintln!("Error: Could not deserialize TOML file. {e}");
eprintln!(
"{} {}",
"Error: Could not deserialize TOML file.".paint(Color::Red),
e.paint(Color::Red)
);
std::process::exit(1);
}
},
Err(_) => {
eprintln!("Error: Could not read config file.");
eprintln!("{}", "Error: Could not read config file.".paint(Color::Red));
std::process::exit(1);
}
};
// TODO : Show config
println!("Config: {conf:?}");
println!("\nDo you want to proceed with this configuration? (yes/no)");
print!("\nDo you want to proceed with this configuration? (yes/no) ");
let mut input = String::new();
std::io::stdout().flush().expect("Error flushing stdout.");