diff --git a/cove-config/src/doc.rs b/cove-config/src/doc.rs index dc232f4..4a344a0 100644 --- a/cove-config/src/doc.rs +++ b/cove-config/src/doc.rs @@ -1,6 +1,10 @@ +//! Auto-generate markdown documentation. + use std::collections::HashMap; use std::path::PathBuf; +pub use cove_macro::Document; + #[derive(Clone, Default)] pub struct ValueInfo { pub required: Option, diff --git a/cove-config/src/euph.rs b/cove-config/src/euph.rs new file mode 100644 index 0000000..2c50c24 --- /dev/null +++ b/cove-config/src/euph.rs @@ -0,0 +1,55 @@ +use std::collections::HashMap; + +use serde::Deserialize; + +use crate::doc::{Doc, Document}; + +#[derive(Debug, Clone, Copy, Default, Deserialize)] +#[serde(rename_all = "snake_case")] +pub enum RoomsSortOrder { + #[default] + Alphabet, + Importance, +} + +impl Document for RoomsSortOrder { + fn doc() -> Doc { + let mut doc = String::doc(); + doc.value_info.values = Some(vec![ + // TODO Generate by serializing + "`alphabet`".to_string(), + "`importance`".to_string(), + ]); + doc + } +} + +// TODO Mark favourite rooms via printable ascii characters +#[derive(Debug, Clone, Default, Deserialize, Document)] +pub struct EuphRoom { + /// Whether to automatically join this room on startup. + #[serde(default)] + #[document(default = "`false`")] + pub autojoin: bool, + + /// If set, cove will set this username upon joining if there is no username + /// associated with the current session. + pub username: Option, + + /// If `euph.rooms..username` is set, this will force cove to set the + /// username even if there is already a different username associated with + /// the current session. + #[serde(default)] + #[document(default = "`false`")] + pub force_username: bool, + + /// If set, cove will try once to use this password to authenticate, should + /// the room be password-protected. + pub password: Option, +} + +#[derive(Debug, Default, Deserialize, Document)] +pub struct Euph { + #[document(metavar = "room")] + pub rooms: HashMap, +} diff --git a/cove-config/src/lib.rs b/cove-config/src/lib.rs index 1f17988..9b81c28 100644 --- a/cove-config/src/lib.rs +++ b/cove-config/src/lib.rs @@ -10,64 +10,15 @@ #![warn(clippy::use_self)] pub mod doc; +mod euph; -use std::collections::HashMap; use std::fs; use std::path::{Path, PathBuf}; -use cove_macro::Document; -use doc::{Doc, Document}; +use doc::Document; use serde::Deserialize; -#[derive(Debug, Clone, Copy, Default, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum RoomsSortOrder { - #[default] - Alphabet, - Importance, -} - -impl Document for RoomsSortOrder { - fn doc() -> Doc { - let mut doc = String::doc(); - doc.value_info.values = Some(vec![ - // TODO Generate by serializing - "`alphabet`".to_string(), - "`importance`".to_string(), - ]); - doc - } -} - -// TODO Mark favourite rooms via printable ascii characters -#[derive(Debug, Clone, Default, Deserialize, Document)] -pub struct EuphRoom { - /// Whether to automatically join this room on startup. - #[serde(default)] - #[document(default = "`false`")] - pub autojoin: bool, - - /// If set, cove will set this username upon joining if there is no username - /// associated with the current session. - pub username: Option, - - /// If `euph.rooms..username` is set, this will force cove to set the - /// username even if there is already a different username associated with - /// the current session. - #[serde(default)] - #[document(default = "`false`")] - pub force_username: bool, - - /// If set, cove will try once to use this password to authenticate, should - /// the room be password-protected. - pub password: Option, -} - -#[derive(Debug, Default, Deserialize, Document)] -pub struct Euph { - #[document(metavar = "room")] - pub rooms: HashMap, -} +pub use crate::euph::*; #[derive(Debug, Default, Deserialize, Document)] pub struct Config {