aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml3
-rw-r--r--src/main.rs31
2 files changed, 28 insertions, 6 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 5469a29..0302432 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
1[package] 1[package]
2name = "prompt" 2name = "pista"
3version = "0.1.0" 3version = "0.1.0"
4authors = ["NerdyPepper <[email protected]>"] 4authors = ["NerdyPepper <[email protected]>"]
5edition = "2018" 5edition = "2018"
@@ -10,3 +10,4 @@ tico = "1.0.0"
10libc = "0.2.55" 10libc = "0.2.55"
11colored = "1.8.0" 11colored = "1.8.0"
12git2 = "0.8.0" 12git2 = "0.8.0"
13clap = "2.33.0"
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 )