aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs66
1 files changed, 48 insertions, 18 deletions
diff --git a/src/main.rs b/src/main.rs
index 2a748cf..2f9063e 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,6 +18,8 @@ mod system_info;
mod vcs;
fn collect_data() -> prompt::PromptData {
+ start_talking_about_time!("collecting data");
+
let matches = clap::App::new("fancy-prompt")
.about("Prints a fancy prompt")
// XXX author, version (extract from cargo)
@@ -32,29 +34,57 @@ fn collect_data() -> prompt::PromptData {
)
.get_matches();
+ let shell = matches
+ .value_of("prompt-escape")
+ .map(|shell| colors::ShellType::from_str(shell))
+ .unwrap_or(colors::ShellType::Unknown);
+ let error_code = matches
+ .value_of("error-code")
+ .map(|code| code.parse().expect("error code must be a u8"))
+ .unwrap_or(0);
+ talk_about_time!("command line arg parsing");
+
+ let hostname = system_info::hostname();
+ talk_about_time!("hostname");
+ let terminal_cols = system_info::terminal_cols();
+ talk_about_time!("terminal_cols");
+ let pwd = system_info::pwd();
+ talk_about_time!("pwd");
+ let home = system_info::home();
+ talk_about_time!("home");
+ let user = system_info::user();
+ talk_about_time!("user");
+ let is_root = system_info::is_root();
+ talk_about_time!("is_root");
+ let time = system_info::time();
+ talk_about_time!("time");
+ let power_info = system_info::power_info();
+ talk_about_time!("power_info");
+ let vcs_info = system_info::vcs_info();
+ talk_about_time!("vcs_info");
+
+ stop_talking_about_time!();
+
prompt::PromptData {
- shell: matches
- .value_of("prompt-escape")
- .map(|shell| colors::ShellType::from_str(shell))
- .unwrap_or(colors::ShellType::Unknown),
- error_code: matches
- .value_of("error-code")
- .map(|code| code.parse().expect("error code must be a u8"))
- .unwrap_or(0),
-
- hostname: system_info::hostname(),
- terminal_cols: system_info::terminal_cols(),
- pwd: system_info::pwd(),
- home: system_info::home(),
- user: system_info::user(),
- is_root: system_info::is_root(),
- time: system_info::time(),
- power_info: system_info::power_info(),
- vcs_info: system_info::vcs_info(),
+ shell,
+ error_code,
+ hostname,
+ terminal_cols,
+ pwd,
+ home,
+ user,
+ is_root,
+ time,
+ power_info,
+ vcs_info,
}
}
fn main() {
+ start_talking_about_time!("main");
let data = collect_data();
+ talk_about_time!("collecting data");
prompt::Prompt::new(data).display();
+ talk_about_time!("displaying data");
+ stop_talking_about_time!();
}