fix #1 unattended install option
All checks were successful
ci/woodpecker/push/build Pipeline was successful
All checks were successful
ci/woodpecker/push/build Pipeline was successful
This commit is contained in:
parent
601d32bc92
commit
dd581a69f5
3 changed files with 58 additions and 18 deletions
36
src/main.rs
36
src/main.rs
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue