aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-05-14 16:26:14 -0400
committerJesse Luehrs <doy@tozt.net>2018-05-14 16:26:14 -0400
commitf49066fc12bb8766492491daba84e1c068ab5e15 (patch)
treeab09f8ea7fa81434cf21fe5a1b640e4b4a6044a9 /src/main.rs
parent3e4cd71073fb3b30792aaf1443261e966cbbcf4b (diff)
downloadfancy-prompt-f49066fc12bb8766492491daba84e1c068ab5e15.tar.gz
fancy-prompt-f49066fc12bb8766492491daba84e1c068ab5e15.zip
reorganize a bit
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs71
1 files changed, 5 insertions, 66 deletions
diff --git a/src/main.rs b/src/main.rs
index 63f73ed..146e633 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,79 +12,18 @@ extern crate walkdir;
#[macro_use]
mod verbose;
+mod args;
mod colors;
+mod data;
mod power;
mod prompt;
-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")
- .author(crate_authors!())
- .version(crate_version!())
- .arg(clap::Arg::with_name("prompt-escape")
- .long("prompt-escape")
- .value_name("SHELL")
- .help("Produces escape sequence wrappers for the given shell")
- .takes_value(true))
- .arg(clap::Arg::with_name("error-code")
- .value_name("ERROR_CODE")
- .help("The error code of the previously run command")
- )
- .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,
- 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();
+ 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");