Browse Source

refactoring: fix clippy warnings in logout execute function

main
fdai7375 2 years ago
parent
commit
4acf28a938
  1. 12
      src/builtins/logout.rs

12
src/builtins/logout.rs

@ -9,13 +9,17 @@ impl Builtin for Logout {
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> { fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
let mut input_confirmation = String::new(); let mut input_confirmation = String::new();
println!("Are you sure? Unsaved data will be lost.\ny/n"); println!("Are you sure? Unsaved data will be lost.\ny/n");
io::stdin().read_line(&mut input_confirmation).expect("Couldn't read form stdin");
if input_confirmation.chars().next().unwrap() == 'y' {
io::stdin()
.read_line(&mut input_confirmation)
.expect("Couldn't read form stdin");
if input_confirmation.starts_with('y') {
match logout() { match logout() {
Ok(_) => println!("Logging out"), Ok(_) => println!("Logging out"),
Err(error) => eprintln!("Failed to log out: {}", error),
Err(error) => eprintln!("Failed to log out: {error}"),
}
} else {
println!("Aborting");
} }
} else { println!("Aborting"); }
Ok(()) Ok(())
} }
} }
Loading…
Cancel
Save