upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/config.rs
blob: f3b7f7b171bf71c503f298a51999dd5098ecb4c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use nostr::{secp256k1::SecretKey};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize)]
pub struct MyConfig {
    version: u8,
    pub default_admin_group_event_serialized: Option<String>,
    pub default_relays:Vec<String>,
    pub private_key:Option<SecretKey>,
}

/// `MyConfig` implements `Default`
impl ::std::default::Default for MyConfig {
    fn default() -> Self { Self {
        version: 0,
        default_admin_group_event_serialized: None,
        default_relays:vec![],
        private_key: None,
    } }
}

pub fn load_config() -> MyConfig {
    confy::load("ngit-cli", None)
        .expect("load_config always to load confy custom config or defaults for ngit-cli")
}

pub fn save_conifg(cfg:&MyConfig) -> &MyConfig {
    confy::store("ngit-cli",None, &cfg)
        .expect("save_conifg always to save confy custom config or defaults for ngit-cli and return it");
    cfg
}