summaryrefslogtreecommitdiffstats
path: root/src/commands/quit.rs
blob: 3ed1d76f5c4fd25d1df29b62242ae20c9fc631cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::context::JoshutoContext;
use crate::error::{JoshutoError, JoshutoErrorKind, JoshutoResult};

pub fn quit(context: &mut JoshutoContext) -> JoshutoResult<()> {
    if context.worker_is_busy() {
        Err(JoshutoError::new(
            JoshutoErrorKind::IoOther,
            String::from("operations running in background, use force_quit to quit"),
        ))
    } else {
        context.exit = true;
        Ok(())
    }
}

pub fn force_quit(context: &mut JoshutoContext) -> JoshutoResult<()> {
    context.exit = true;
    Ok(())
}