aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: 70c6adfd8270d4bc4e531553f7baef1f3a846789 (plain) (blame)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
extern crate chrono;
#[macro_use]
extern crate clap;
extern crate git2;
extern crate hostname;
extern crate regex;
extern crate term;
extern crate term_size;
extern crate users;
extern crate walkdir;

#[macro_use]
mod verbose;

mod args;
mod colors;
mod data;
mod power;
mod prompt;
mod sys;
mod vcs;

fn main() {
    start_talking_about_time!("main");
    let opts = args::parse();
    talk_about_time!("parsing args");
    let data = data::collect(opts);
    talk_about_time!("collecting data");
    prompt::Prompt::new(data).display();
    talk_about_time!("displaying data");
    stop_talking_about_time!();
}

#[cfg(test)]
mod tests {
    use super::*;
    use chrono::TimeZone;

    #[test]
    fn test_render() {
        let data = data::PromptData {
            shell: colors::ShellType::Unknown,
            error_code: 0,
            hostname: Some(String::from("hush")),
            terminal_cols: Some(80),
            pwd: Some(std::path::PathBuf::from("/home/doy/coding/fancy-prompt")),
            home: Some(std::path::PathBuf::from("/home/doy")),
            user: Some(String::from("doy")),
            is_root: false,
            time: chrono::Local.ymd(2018, 5, 14).and_hms(17, 35, 45),
            power_info: power::PowerInfo::new(),
            vcs_info: None,
        };
        prompt::Prompt::new(data).display();
    }
}