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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
mod setup;
use crate::{
core::setup::{setup_gw_dir, setup_init_state},
glyph::Glyph,
plugins,
statehandler::{self, State},
tui,
};
use std::{error::Error, path::PathBuf};
pub fn init(path: Option<PathBuf>, headless: bool, refresh: bool) -> Result<(), Box<dyn Error>> {
setup_gw_dir(path, headless, refresh)?;
setup_init_state()?;
Ok(())
}
pub fn add(
glyph: Glyph,
location: PathBuf,
existing: bool,
active: bool,
default: bool,
) -> Result<(), Box<dyn Error>> {
if !existing {
plugins::invoke("Weaver", None)?;
}
statehandler::add_state(glyph, location, None, active, default)?;
Ok(())
}
pub fn remove(glyph: Glyph) -> Result<(), Box<dyn Error>> {
statehandler::purge_state(glyph)?;
Ok(())
}
pub fn list() -> Result<Vec<State>, Box<dyn Error>> {
let states = statehandler::load_stategraph()?.get_states().to_vec();
Ok(states)
}
pub fn switch(glyph: Glyph, default: bool) -> Result<(), Box<dyn Error>> {
statehandler::set_active(&glyph)?;
if default {
statehandler::set_default(&glyph)?;
}
Ok(())
}
pub fn runsplash() -> Result<(), Box<dyn Error>> {
tui::run()?;
Ok(())
}