changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > demo / obj/src/cfg.rs

changeset 18: a1137af05c8d
author: ellis <ellis@rwest.io>
date: Mon, 29 May 2023 21:46:21 -0400
permissions: -rw-r--r--
description: removed fig, use sexprs instead
1 /// common trait for all config modules. This trait provides functions
2 /// for de/serializing to/from RON, updating fields, and formatting.
3 use serde::{Serialize, Deserialize};
4 use crate::Objective;
5 use std::collections::HashMap as M;
6 use std::path::PathBuf;
7 use std::string::String as S;
8 use std::error::Error as E;
9 use std::boxed::Box as B;
10 type R<X> = std::result::Result<X,B<dyn E>>;
11 
12 pub trait Configure: Objective {
13  fn update(&self) -> R<()> {
14  Ok(())
15  }
16 }
17 
18 #[derive(Serialize, Deserialize, Debug, Default)]
19 pub struct ShellConfig {
20  pub env: M<S,S>,
21  pub cmds: M<S,S>,
22  pub shell: ShellType,
23 }
24 
25 impl Objective for ShellConfig {}
26 
27 #[derive(Serialize, Deserialize, Debug, Hash, Default)]
28 pub enum ShellType {
29  #[default]
30  Bash,
31  Zsh,
32  Sh,
33 }
34 
35 #[derive(Serialize, Deserialize, Debug, Default)]
36 pub enum EditorType {
37  #[default]
38  Emacs,
39  Vi,
40  Nano,
41 }
42 
43 #[derive(Serialize, Deserialize, Debug, Default)]
44 pub struct EditorConfig {
45  pub editor: EditorType,
46  pub cmds: M<S,S>,
47  pub init_file: PathBuf,
48 }
49 
50 #[cfg(test)]
51 mod tests;