Extract euph config into submodule
This commit is contained in:
parent
478e3e767c
commit
5a0efd69e4
3 changed files with 62 additions and 52 deletions
|
|
@ -1,6 +1,10 @@
|
||||||
|
//! Auto-generate markdown documentation.
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
pub use cove_macro::Document;
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
pub struct ValueInfo {
|
pub struct ValueInfo {
|
||||||
pub required: Option<bool>,
|
pub required: Option<bool>,
|
||||||
|
|
|
||||||
55
cove-config/src/euph.rs
Normal file
55
cove-config/src/euph.rs
Normal file
|
|
@ -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<String>,
|
||||||
|
|
||||||
|
/// If `euph.rooms.<room>.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<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Deserialize, Document)]
|
||||||
|
pub struct Euph {
|
||||||
|
#[document(metavar = "room")]
|
||||||
|
pub rooms: HashMap<String, EuphRoom>,
|
||||||
|
}
|
||||||
|
|
@ -10,64 +10,15 @@
|
||||||
#![warn(clippy::use_self)]
|
#![warn(clippy::use_self)]
|
||||||
|
|
||||||
pub mod doc;
|
pub mod doc;
|
||||||
|
mod euph;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use cove_macro::Document;
|
use doc::Document;
|
||||||
use doc::{Doc, Document};
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default, Deserialize)]
|
pub use crate::euph::*;
|
||||||
#[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<String>,
|
|
||||||
|
|
||||||
/// If `euph.rooms.<room>.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<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Document)]
|
|
||||||
pub struct Euph {
|
|
||||||
#[document(metavar = "room")]
|
|
||||||
pub rooms: HashMap<String, EuphRoom>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, Document)]
|
#[derive(Debug, Default, Deserialize, Document)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue