use serde::Deserialize; use std::collections::HashMap; #[derive(Debug, Deserialize, Clone)] pub struct MenuRoot { pub version: String, pub menu: Vec, } #[derive(Debug, Deserialize, Clone)] pub struct MenuItem { pub id: String, pub title: String, pub description: Option, #[serde(flatten)] pub kind: MenuItemKind, } #[derive(Debug, Deserialize, Clone)] #[serde(untagged)] pub enum MenuItemKind { Category { children: Vec }, Action { action: Action }, } #[derive(Debug, Deserialize, Clone)] #[serde(tag = "type", rename_all = "lowercase")] pub enum Action { Bash { script: String, #[serde(default = "default_interaction")] interaction: InteractionMode, #[serde(default)] confirm: bool, }, Download { url: String, filename: Option, target_dir: Option, #[serde(default)] confirm: bool, }, DownloadAndRun { url: String, filename: Option, run_args: Vec, #[serde(default)] keep_file: bool, #[serde(default)] confirm: bool, }, HttpRequest { method: HttpMethod, url: String, headers: std::collections::HashMap, body: Option, #[serde(default)] confirm: bool, }, } #[derive(Debug, Deserialize, Clone)] #[serde(rename_all = "lowercase")] pub enum InteractionMode { Terminal, Structured, } fn default_interaction() -> InteractionMode { InteractionMode::Terminal } #[derive(Debug, Deserialize, Clone)] #[serde(rename_all = "UPPERCASE")] pub enum HttpMethod { Get, Post, Put, Delete, }