command line warnings
This commit is contained in:
@@ -39,40 +39,36 @@ impl AppTerminal {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn handle_command(&mut self, command_input: &str, is_saved: &mut bool) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
pub fn handle_command(&mut self, command_input: &str, is_saved: &mut bool) -> Result<(bool, String), Box<dyn std::error::Error>> {
|
||||
match command_input {
|
||||
"w" => {
|
||||
// Save the state
|
||||
*is_saved = true;
|
||||
println!("State saved.");
|
||||
Ok(false) // Do not exit
|
||||
Ok((false, "State saved.".to_string())) // Do not exit
|
||||
}
|
||||
"q" => {
|
||||
// Quit if saved
|
||||
if *is_saved {
|
||||
self.cleanup()?;
|
||||
Ok(true) // Exit
|
||||
Ok((true, "Exiting.".to_string())) // Exit
|
||||
} else {
|
||||
println!("No changes saved. Use :q! to force quit.");
|
||||
Ok(false) // Do not exit
|
||||
Ok((false, "No changes saved. Use :q! to force quit.".to_string())) // Do not exit
|
||||
}
|
||||
}
|
||||
"q!" => {
|
||||
// Force quit without saving
|
||||
self.cleanup()?;
|
||||
Ok(true) // Exit
|
||||
Ok((true, "Force exiting without saving.".to_string())) // Exit
|
||||
}
|
||||
"wq" => {
|
||||
// Save and quit
|
||||
*is_saved = true;
|
||||
println!("State saved.");
|
||||
self.cleanup()?;
|
||||
Ok(true) // Exit
|
||||
Ok((true, "State saved. Exiting.".to_string())) // Exit
|
||||
}
|
||||
_ => {
|
||||
// Handle other commands here
|
||||
println!("Command not recognized: {}", command_input);
|
||||
Ok(false) // Do not exit
|
||||
Ok((false, format!("Command not recognized: {}", command_input))) // Do not exit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user