2026-07-11 18:23:01 +07:00
|
|
|
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)]
|
|
|
|
|
}
|
2026-07-11 21:06:22 +07:00
|
|
|
Command::LessonAccept(name) => {
|
|
|
|
|
vec![Action::LessonAccept { name }]
|
|
|
|
|
}
|
|
|
|
|
Command::LessonReject(name) => {
|
|
|
|
|
vec![Action::LessonReject { name }]
|
|
|
|
|
}
|
2026-07-11 18:23:01 +07:00
|
|
|
Command::Mode(mode) => {
|
|
|
|
|
vec![Action::SwitchMode(mode)]
|
|
|
|
|
}
|
|
|
|
|
Command::Clear => {
|
|
|
|
|
vec![Action::SystemNote {
|
|
|
|
|
kind: "clear".to_string(),
|
|
|
|
|
message: "transcript cleared".to_string(),
|
|
|
|
|
}]
|
|
|
|
|
}
|
2026-07-11 20:21:59 +07:00
|
|
|
Command::Login { provider } => {
|
2026-07-11 18:23:01 +07:00
|
|
|
vec![Action::SystemNote {
|
2026-07-11 20:21:59 +07:00
|
|
|
kind: "oauth".to_string(),
|
|
|
|
|
message: format!("OAuth login flow started for {}", provider),
|
2026-07-11 18:23:01 +07:00
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
Command::Unknown(cmd) => {
|
|
|
|
|
vec![Action::SystemNote {
|
|
|
|
|
kind: "error".to_string(),
|
|
|
|
|
message: format!("unknown command: {}", cmd),
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|