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
33
34
35
36
37
38
39
40
/// macro to raise the error specified
#[macro_export]
macro_rules! pier_err {
    ($type:expr) => {
        return Err($type)?;
    };
}

/// macro to return an absolute path base on the relative_path from $XDG_CONFIG_HOME
#[macro_export]
macro_rules! xdg_config_home {
    ($relative_path:expr) => {
        match dirs::config_dir() {
            Some(base) => Some(base.join($relative_path)),
            None => None,
        }
    };
}

/// macro to return an absolute path base on the relative_path from $HOME
#[macro_export]
macro_rules! home {
    ($relative_path:expr) => {
        match dirs::home_dir() {
            Some(base) => Some(base.join($relative_path)),
            None => None,
        }
    };
}

///
#[macro_export]
macro_rules! clap_arg {
    ($relative_path:expr) => {
        match dirs::home_dir() {
            Some(base) => Some(base.join($relative_path)),
            None => None,
        }
    };
}