From ef5703f282ca6fc5bbc5101344fbccb16dd51bc7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Thu, 25 Apr 2024 04:25:25 -0700 Subject: [PATCH] condense prompt logic --- src/main.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 13860c5..c9a1a86 100644 --- a/src/main.rs +++ b/src/main.rs @@ -430,18 +430,16 @@ fn upload() -> AResult<()>{ //Creator: [auto fill creator] //DisplayName: [auto fill DisplayName] //id: ["New" for blank because of my double enter key] - print!("Model name: {}\nCreator: {}\nDisplayName: {}\nAction or Upload Asset Id: ",modelname,creator,displayname); - std::io::Write::flush(&mut std::io::stdout())?; + print!("Model name: {}\nCreator: {}\nDisplayName: {}\n",modelname,creator,displayname); let upload_action; loop{ + print!("Action or Upload Asset Id: "); + std::io::Write::flush(&mut std::io::stdout())?; let mut upload_action_string = String::new(); std::io::stdin().read_line(&mut upload_action_string)?; if let Ok(parsed_upload_action)=upload_action_string.parse::(){ upload_action=parsed_upload_action; break; - }else{ - print!("Action or Upload Asset Id: "); - std::io::Write::flush(&mut std::io::stdout())?; } } match upload_action { @@ -569,22 +567,20 @@ fn interactive() -> AResult<()>{ ScriptAction::Replace(*replace_id) }else{ //interactive logic goes here - print!("unresolved source location={}\naction: ",get_full_name(&dom, script)); - std::io::Write::flush(&mut std::io::stdout())?; + print!("unresolved source location={}\n",get_full_name(&dom, script)); //load source into current.lua std::fs::write("current.lua",source)?; //prompt action in terminal //wait for input let script_action; loop{ + print!("action: "); + std::io::Write::flush(&mut std::io::stdout())?; let mut action_string = String::new(); std::io::stdin().read_line(&mut action_string)?; if let Ok(parsed_script_action)=action_string.parse::(){ script_action=parsed_script_action; break; - }else{ - print!("action: "); - std::io::Write::flush(&mut std::io::stdout())?; } } //update allowed/replace/blocked