cses-cli 0.1.4

CSES CLI is a lightweight tool for using CSES from the command line.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use anyhow::{anyhow, Result};

use crate::entities::Scope;
use crate::{Resources, Storage, RP};

pub fn select_scope(res: &mut Resources<impl RP>, changed_scope: Option<Scope>) -> Result<Scope> {
    if let Some(scope) = changed_scope {
        res.storage.get_mut().set_scope(scope);
        res.storage.save()?;
    }
    res.storage
        .get()
        .get_scope()
        .ok_or_else(|| anyhow!("Course or contest not provided"))
}