//! Application commands: `app.about` and `app.quit`. use serde_json::{Value, json}; use crate::{Command, CommandSpec, Effect, EngineError, Outcome, State}; /// Product name shown in the About window and window titles. pub const PRODUCT_NAME: &str = "Lutra"; /// Product slogan. pub const SLOGAN: &str = "An otterly perfect IDE"; /// `app.about`: returns the product name, version and slogan. pub struct About; impl Command for About { fn spec(&self) -> &CommandSpec { &CommandSpec { id: "app.about", label: "About Lutra", menu_path: Some("Help/About Lutra"), default_shortcut: None, params: "none; returns { name, version, slogan }", } } fn run(&self, _state: &mut State, _params: Value) -> Result { Ok(Outcome::value(json!({ "name": PRODUCT_NAME, "version": env!("CARGO_PKG_VERSION"), "slogan": SLOGAN, }))) } } /// `app.quit`: asks the host to quit the application. pub struct Quit; impl Command for Quit { fn spec(&self) -> &CommandSpec { &CommandSpec { id: "app.quit", label: "Quit", menu_path: Some("File/Quit"), default_shortcut: Some("Mod+Q"), params: "none; returns null and the effect quit", } } fn run(&self, state: &mut State, _params: Value) -> Result { crate::cmd::terminal::close_all(state); Ok(Outcome::effect(Effect::Quit)) } }