swordfishlib/
lib.rs

1mod commands;
2mod terminal;
3mod functions;
4mod state;
5
6use anyhow::Result;
7use commands::Command;
8use state::State;
9use commands::Runnable;
10
11pub fn from_yaml(data: &str) -> Result<Vec<Command>> {
12    let yaml = serde_yaml::from_str(data)?;
13    Ok(yaml)
14}
15
16const DELAY_AFTER_EXECUTE: u32 = 250;
17
18pub fn execute(commands: Vec<Command>) -> Result<()> {
19    let mut state = State {
20        prompt: None,
21        cursor: 0,
22        speed_factor: 1,
23    };
24
25    for cmd in commands {
26        cmd.run(&mut state)?;
27    }
28
29    Ok(())
30}