aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index e0b8f41..cee0c21 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,8 +3,24 @@ mod prompt_char;
3mod vcs; 3mod vcs;
4mod venv; 4mod venv;
5 5
6use clap::{Arg, App};
7
6fn main() { 8fn main() {
7 println!("{}", pista()); 9 let matches = App::new("Pista")
10 .version(env!("CARGO_PKG_VERSION"))
11 .author(env!("CARGO_PKG_AUTHORS"))
12 .about(env!("CARGO_PKG_DESCRIPTION"))
13 .arg(Arg::with_name("minimal")
14 .short("m")
15 .long("minimal")
16 .help("use minimal variant")
17 )
18 .get_matches();
19 if matches.is_present("minimal") {
20 println!("{}", pista_minimal());
21 } else {
22 println!("{}", pista());
23 }
8} 24}
9 25
10fn pista() -> String { 26fn pista() -> String {
@@ -23,13 +39,18 @@ fn pista() -> String {
23 39
24fn pista_minimal() -> String { 40fn pista_minimal() -> String {
25 let cwd = cwd::cwd(); 41 let cwd = cwd::cwd();
26 let (branch, status) = vcs::vcs_status().unwrap_or(("".into(), "".into())); 42 let vcs_tuple = vcs::vcs_status();
43 let mut vcs_component = String::new();
44 if let Some((branch, status)) = vcs_tuple {
45 vcs_component = format!(" [{} {}] ", branch, status);
46 } else {
47 vcs_component.push(' ');
48 }
27 let venv = venv::get_name(); 49 let venv = venv::get_name();
28 let prompt_char = prompt_char::get_char(); 50 let prompt_char = prompt_char::get_char();
29 format!("{cwd} {branch}{status}{venv}{pchar}", 51 format!("{cwd}{vcs}{venv}{pchar} ",
30 cwd=cwd, 52 cwd=cwd,
31 branch=branch, 53 vcs=vcs_component,
32 status=status,
33 venv=venv, 54 venv=venv,
34 pchar=prompt_char 55 pchar=prompt_char
35 ) 56 )