refactor
This commit is contained in:
parent
eabd898ccf
commit
f2b1a43f62
13 changed files with 453 additions and 390 deletions
31
src/main.rs
31
src/main.rs
|
@ -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.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue