1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::state::ChrsSessions;
use chris::types::{CubeUrl, PluginInstanceId, Username};
use color_eyre::eyre;
use std::path::PathBuf;

pub fn set_cd(
    cube_url: &CubeUrl,
    username: &Username,
    id: PluginInstanceId,
    config_path: Option<PathBuf>,
) -> eyre::Result<()> {
    let mut sessions = ChrsSessions::load(config_path.as_deref())?;
    if sessions.set_plugin_instance(cube_url, username, id) {
        sessions.save(config_path.as_deref())?;
    }
    Ok(())
}