Browse Source

refactoring: reformat and import sort

main
fdai7374 2 years ago
committed by fdai7451
parent
commit
0346fac62a
  1. 8
      src/builtins/logout.rs

8
src/builtins/logout.rs

@ -1,16 +1,16 @@
use crate::builtins::{Builtin, BuiltinConfig};
use crate::error::ShellError;
use system_shutdown::logout;
use std::io;
use system_shutdown::logout;
pub struct Logout;
impl Builtin for Logout {
fn execute(&mut self, _: &mut BuiltinConfig, _: Vec<String>) -> Result<(), ShellError> {
let mut input = String::new();
let mut input_confirmation = String::new();
println!("Are you sure? Unsaved data will be lost.\ny/n");
io::stdin().read_line(&mut input).expect("Couldn't read form stdin");
if input.chars().next().unwrap()=='y' {
io::stdin().read_line(&mut input_confirmation).expect("Couldn't read form stdin");
if input_confirmation.chars().next().unwrap() == 'y' {
match logout() {
Ok(_) => println!("Logging out"),
Err(error) => eprintln!("Failed to log out: {}", error),

Loading…
Cancel
Save