Skip to content

Commit f0b718e

Browse files
committedApr 8, 2019
add last change #28
1 parent d6d3694 commit f0b718e

File tree

4 files changed

+37
-8
lines changed

4 files changed

+37
-8
lines changed
 

Diff for: ‎assets/cpp.png

-5.4 KB
Loading

Diff for: ‎assets/haskell.png

7.71 KB
Loading

Diff for: ‎resources/cpp.ascii

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

2-
_____
3-
/ ____|_ _
4-
| | _| |_ _| |_
5-
| | |_ _|_ _|
6-
| |____|_| |_|
7-
\_____|
2+
{0} _____
3+
{0} / ____|{1}_ _
4+
{0} | | {1}_| |_ _| |_
5+
{0} | | {1}|_ _|_ _|
6+
{0} | |____{1}|_| |_|
7+
{0} \_____|
88

Diff for: ‎src/main.rs

+31-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct Info {
3030
dominant_language: Language,
3131
languages: Vec<(Language, f64)>,
3232
authors: Vec<String>,
33+
last_change: String,
3334
repo: String,
3435
commits: String,
3536
number_of_lines: usize,
@@ -99,6 +100,13 @@ impl fmt::Display for Info {
99100
}
100101
}
101102

103+
writeln!(
104+
buffer,
105+
"{}{}",
106+
"Last change: ".color(color).bold(),
107+
self.last_change
108+
)?;
109+
102110
writeln!(buffer, "{}{}", "Repo: ".color(color).bold(), self.repo)?;
103111
writeln!(
104112
buffer,
@@ -109,7 +117,7 @@ impl fmt::Display for Info {
109117
writeln!(
110118
buffer,
111119
"{}{}",
112-
"Number of lines: ".color(color).bold(),
120+
"Lines of code: ".color(color).bold(),
113121
self.number_of_lines
114122
)?;
115123
writeln!(
@@ -288,13 +296,15 @@ fn main() -> Result<()> {
288296
let config = get_configuration(&dir)?;
289297
let version = get_version(&dir)?;
290298
let commits = get_commits(&dir)?;
299+
let last_change = get_last_change(&dir)?;
291300

292301
let info = Info {
293302
project_name: config.repository_name,
294303
version,
295304
dominant_language,
296305
languages: languages_stat_vec,
297306
authors,
307+
last_change,
298308
repo: config.repository_url,
299309
commits,
300310
number_of_lines: get_total_loc(&tokei_langs),
@@ -380,6 +390,25 @@ fn get_version(dir: &str) -> Result<String> {
380390
}
381391
}
382392

393+
fn get_last_change(dir: &str) -> Result<String> {
394+
let output = Command::new("git")
395+
.arg("-C")
396+
.arg(dir)
397+
.arg("log")
398+
.arg("-1")
399+
.arg("--format=%cr")
400+
.output()
401+
.expect("Failed to execute git.");
402+
403+
let output = String::from_utf8_lossy(&output.stdout);
404+
405+
if output == "" {
406+
Ok("??".into())
407+
} else {
408+
Ok(output.to_string().replace('\n', ""))
409+
}
410+
}
411+
383412
fn get_commits(dir: &str) -> Result<String> {
384413
let output = Command::new("git")
385414
.arg("-C")
@@ -576,7 +605,7 @@ impl Info {
576605
match self.dominant_language {
577606
Language::C => vec![Color::BrightBlue, Color::Blue],
578607
Language::Clojure => vec![Color::BrightBlue, Color::BrightGreen],
579-
Language::Cpp => vec![Color::Yellow],
608+
Language::Cpp => vec![Color::Yellow, Color::Cyan],
580609
Language::Csharp => vec![Color::White],
581610
Language::Go => vec![Color::White],
582611
Language::Haskell => vec![Color::BrightBlue, Color::BrightMagenta, Color::Blue],

0 commit comments

Comments
 (0)
Please sign in to comment.