1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use std::io;
use crate::command_handler::CommandHandler;

/// Ready-to-use command to quit the cmd loop
///
/// Return code 0 instructs the Cmd.run() loop to break
#[derive(Debug, Default)]
pub struct Quit {}

impl<W: io::Write> CommandHandler<W> for Quit {
    fn execute(&self, _cmd: &mut W, _args: String) -> usize {
        0
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_quit(){
        let q = Quit::default();
        assert_eq!(q.execute(&mut io::stdout(), "".to_string()), 0)
    }
}