fix #1 unattended install option
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
JMARyA 2025-01-06 09:36:21 +01:00
parent 601d32bc92
commit dd581a69f5
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 58 additions and 18 deletions

View file

@ -39,8 +39,9 @@ fn main() {
let kb_layout: &String = iso_args.get_one("kb_layout").unwrap_or(&kb_layout_default);
let kb_variant: Option<&str> =
iso_args.get_one("kb_variant").map(|x: &String| x.as_str());
let auto_install_config: Option<&String> = iso_args.get_one("install");
create_iso(without_gui, kb_layout, kb_variant);
create_iso(without_gui, kb_layout, kb_variant, auto_install_config);
std::process::exit(0);
}
Some(("create-tar", _)) => {
@ -79,6 +80,7 @@ fn main() {
}
let config_file: &String = install_args.get_one("config").unwrap();
let force = install_args.get_flag("force");
let config_content = std::fs::read_to_string(config_file);
let conf: InstallConfig = match config_content {
@ -99,19 +101,10 @@ fn main() {
}
};
print_config(&conf);
print!("Do you want to proceed with this configuration? (yes/no) ");
let mut input = String::new();
std::io::stdout().flush().expect("Error flushing stdout.");
std::io::stdin()
.read_line(&mut input)
.expect("Error reading input.");
let input = input.trim().to_lowercase();
if input != "yes" {
println!("Installation aborted.");
std::process::exit(0);
if !force {
print_config(&conf);
print!("Do you want to proceed with this configuration? (yes/no) ");
expect_yes();
}
// Run the
@ -120,3 +113,18 @@ fn main() {
_ => {}
}
}
/// Read user input and exit if the input is not "yes"
pub fn expect_yes() {
let mut input = String::new();
std::io::stdout().flush().expect("Error flushing stdout.");
std::io::stdin()
.read_line(&mut input)
.expect("Error reading input.");
let input = input.trim().to_lowercase();
if input != "yes" {
println!("Installation aborted.");
std::process::exit(0);
}
}