Document config
This commit is contained in:
parent
f2c3011888
commit
3d91d447c7
3 changed files with 72 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -275,6 +275,7 @@ dependencies = [
|
|||
name = "cove-config"
|
||||
version = "0.6.1"
|
||||
dependencies = [
|
||||
"cove-macro",
|
||||
"serde",
|
||||
"toml",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -4,5 +4,7 @@ version = { workspace = true }
|
|||
edition = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
cove-macro = { path = "../cove-macro" }
|
||||
|
||||
serde = { version = "1.0.159", features = ["derive"] }
|
||||
toml = "0.7.3"
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ use std::collections::HashMap;
|
|||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use cove_macro::Document;
|
||||
use doc::{Doc, Document};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, Deserialize)]
|
||||
|
|
@ -25,31 +27,94 @@ pub enum RoomsSortOrder {
|
|||
Importance,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Deserialize)]
|
||||
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 {
|
||||
// TODO Mark favourite rooms via printable ascii characters
|
||||
/// 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)]
|
||||
#[derive(Debug, Default, Deserialize, Document)]
|
||||
pub struct Euph {
|
||||
#[document(metavar = "room")]
|
||||
pub rooms: HashMap<String, EuphRoom>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
#[derive(Debug, Default, Deserialize, Document)]
|
||||
pub struct Config {
|
||||
/// The directory that cove stores its data in when not running in ephemeral
|
||||
/// mode.
|
||||
///
|
||||
/// Relative paths are interpreted relative to the user's home directory.
|
||||
///
|
||||
/// See also the `--data-dir` command line option.
|
||||
#[document(default = "platform-dependent")]
|
||||
pub data_dir: Option<PathBuf>,
|
||||
|
||||
/// Whether to start in ephemeral mode.
|
||||
///
|
||||
/// In ephemeral mode, cove doesn't store any data. It completely ignores
|
||||
/// any options related to the data dir.
|
||||
///
|
||||
/// See also the `--ephemeral` command line option.
|
||||
#[serde(default)]
|
||||
#[document(default = "`false`")]
|
||||
pub ephemeral: bool,
|
||||
|
||||
/// Whether to start in offline mode.
|
||||
///
|
||||
/// In offline mode, cove won't automatically join rooms marked via the
|
||||
/// `autojoin` option on startup. You can still join those rooms manually by
|
||||
/// pressing `a` in the rooms list.
|
||||
///
|
||||
/// See also the `--offline` command line option.
|
||||
#[serde(default)]
|
||||
#[document(default = "`false`")]
|
||||
pub offline: bool,
|
||||
|
||||
/// Initial sort order of rooms list.
|
||||
///
|
||||
/// `alphabet` sorts rooms in alphabetic order.
|
||||
///
|
||||
/// `importance` sorts rooms by the following criteria (in descending order
|
||||
/// of priority):
|
||||
///
|
||||
/// 1. connected rooms before unconnected rooms
|
||||
/// 2. rooms with unread messages before rooms without
|
||||
/// 3. alphabetic order
|
||||
#[serde(default)]
|
||||
#[document(default = "`alphabet`")]
|
||||
pub rooms_sort_order: RoomsSortOrder,
|
||||
|
||||
// TODO Invoke external notification command?
|
||||
pub euph: Euph,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue