gr/
lib.rs

1use std::path::PathBuf;
2
3pub mod api_defaults;
4pub mod api_traits;
5pub mod cache;
6pub mod cli;
7pub mod config;
8pub mod dialog;
9pub mod error;
10pub mod exec;
11pub mod git;
12pub mod github;
13pub mod gitlab;
14pub mod http;
15pub mod init;
16pub mod io;
17pub mod remote;
18pub mod shell;
19pub mod test;
20pub mod time;
21pub type Result<T> = anyhow::Result<T>;
22pub type Error = anyhow::Error;
23pub type Cmd<T> = Box<dyn FnOnce() -> Result<T> + Send + Sync>;
24pub mod backoff;
25pub mod cmds;
26pub mod display;
27pub mod logging;
28
29#[macro_use]
30extern crate log;
31
32#[macro_use]
33extern crate lazy_static;
34
35#[macro_use]
36extern crate derive_builder;
37
38fn json_load_page(data: &str) -> Result<Vec<serde_json::Value>> {
39    serde_json::from_str(data).map_err(|e| error::gen(e.to_string()))
40}
41
42fn json_loads(data: &str) -> Result<serde_json::Value> {
43    serde_json::from_str(data).map_err(|e| error::gen(e.to_string()))
44}
45
46pub const USER_GUIDE_URL: &str = "https://jordilin.github.io/gitar";
47
48lazy_static! {
49    pub static ref DEFAULT_CONFIG_PATH: PathBuf = {
50        let home = std::env::var("HOME").unwrap();
51        PathBuf::from(home).join(".config/gitar")
52    };
53}
54
55pub fn get_default_config_path() -> &'static PathBuf {
56    &DEFAULT_CONFIG_PATH
57}