Files
zesdex/src/app/runtime/commands.rs
T

57 lines
1.7 KiB
Rust
Raw Normal View History

use crate::controller::command::Command;
use crate::app::runtime::actions::Action;
use crate::app::state::types::Overlay;
pub fn apply_command(command: Command) -> Vec<Action> {
match command {
Command::Help => {
vec![Action::OpenOverlay(Overlay::Help)]
}
Command::Quit => {
vec![Action::QuitConfirm]
}
Command::LessonCreate(text) => {
vec![Action::SystemNote {
kind: "lesson".to_string(),
message: format!("/lesson {}", text),
}]
}
Command::LessonExport(path) => {
vec![Action::LessonExport { path }]
}
Command::LessonImport(path) => {
vec![Action::LessonImport { path }]
}
Command::LessonList => {
vec![Action::OpenOverlay(Overlay::Learning)]
}
Command::LessonAccept(name) => {
vec![Action::LessonAccept { name }]
}
Command::LessonReject(name) => {
vec![Action::LessonReject { name }]
}
Command::Mode(mode) => {
vec![Action::SwitchMode(mode)]
}
Command::Clear => {
vec![Action::SystemNote {
kind: "clear".to_string(),
message: "transcript cleared".to_string(),
}]
}
Command::Login { provider } => {
vec![Action::SystemNote {
kind: "oauth".to_string(),
message: format!("OAuth login flow started for {}", provider),
}]
}
Command::Unknown(cmd) => {
vec![Action::SystemNote {
kind: "error".to_string(),
message: format!("unknown command: {}", cmd),
}]
}
}
}