use std::fs; use serde::Deserialize; use toml; #[derive(Deserialize, Debug)] pub struct Service { pub name: String, pub start: Start, pub stop: Option, } #[derive(Deserialize, Debug)] pub struct Start { pub command: String, pub args: Vec } #[derive(Deserialize, Debug)] pub struct Stop { pub command: String, pub args: Vec } pub fn get_services() -> Vec { let mut services = Vec::new(); let paths = fs::read_dir("/etc/mini/").unwrap(); for path in paths { // TODO: check ext let svc_file_contents = fs::read_to_string(path.unwrap().path()).unwrap(); let svc : Service = toml::from_str(&svc_file_contents).unwrap(); services.push(svc); } services }