aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2018-02-19 16:10:02 -0500
committerJesse Luehrs <doy@tozt.net>2018-02-19 16:10:02 -0500
commit0b3404a16019757c891b153485f0583c49f7089f (patch)
tree6b9a3ab625758b8f4d2d102f5c474b1e56ebd339 /src/main.rs
parent5e5157e196ad56b931ee6c052ed0c349a68c6bbf (diff)
downloadfancy-prompt-0b3404a16019757c891b153485f0583c49f7089f.tar.gz
fancy-prompt-0b3404a16019757c891b153485f0583c49f7089f.zip
start sketching out some things
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..471a3a2
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,54 @@
+extern crate chrono;
+extern crate clap;
+extern crate hostname;
+extern crate regex;
+extern crate term;
+extern crate term_size;
+extern crate users;
+extern crate walkdir;
+
+mod colors;
+mod power;
+mod prompt;
+mod system_info;
+
+fn collect_data() -> prompt::PromptData {
+ let matches = clap::App::new("fancy-prompt")
+ .about("Prints a fancy prompt")
+ // XXX author, version (extract from cargo)
+ .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();
+
+ 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(),
+ }
+}
+
+fn main() {
+ let data = collect_data();
+ prompt::Prompt::new(data).display();
+}