From c415ffbdab11c98b4478b74cd418f0fd7c7cb058 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 24 Aug 2024 19:35:27 -0700 Subject: [PATCH] default to current name and confirm override --- src/main.rs | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index adfa17f..6a47c13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -581,8 +581,24 @@ fn interactive() -> AResult<()>{ std::io::Write::flush(&mut std::io::stdout())?; let mut input_string=String::new(); std::io::stdin().read_line(&mut input_string)?; - if model_name_pattern.is_match(input_string.trim()){ - new_model_name=input_string.trim().to_owned(); + let input_final=match input_string.trim(){ + ""=>modelname.as_str(), + other=>other, + }; + if model_name_pattern.is_match(input_final) + ||{ + //If you entered a new model name and it still doesn't like it, allow override + println!("Final model name: {}",input_final); + print!("Are you sure you want this model name? [y/N]:"); + std::io::Write::flush(&mut std::io::stdout())?; + let mut input_string=String::new(); + std::io::stdin().read_line(&mut input_string)?; + match input_string.trim(){ + "y"=>true, + _=>false, + } + }{ + new_model_name=input_final.to_owned(); break; } } @@ -599,8 +615,24 @@ fn interactive() -> AResult<()>{ std::io::Write::flush(&mut std::io::stdout())?; let mut input_string=String::new(); std::io::stdin().read_line(&mut input_string)?; - if is_title_case(input_string.trim()){ - new_display_name=input_string.trim().to_owned(); + let input_final=match input_string.trim(){ + ""=>displayname.as_str(), + other=>other, + }; + if is_title_case(input_string.trim()) + ||{ + //If you entered a new display name and it still doesn't like it, allow override + println!("Final display name: {}",input_final); + print!("Are you sure you want this display name? [y/N]:"); + std::io::Write::flush(&mut std::io::stdout())?; + let mut input_string=String::new(); + std::io::stdin().read_line(&mut input_string)?; + match input_string.trim(){ + "y"=>true, + _=>false, + } + }{ + new_display_name=input_final.to_owned(); break; } }