add colors

This commit is contained in:
JMARyA 2024-03-27 15:43:40 +01:00
parent 5802b1104c
commit bafbb58ff0
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 38 additions and 2 deletions

32
Cargo.lock generated
View file

@ -2,6 +2,15 @@
# It is not intended for manual editing.
version = 3
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "anstream"
version = "0.6.13"
@ -108,6 +117,7 @@ dependencies = [
name = "giterator"
version = "0.1.0"
dependencies = [
"ansi_term",
"clap",
"csv",
"serde_json",
@ -209,6 +219,28 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"

View file

@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
ansi_term = "0.12.1"
clap = { version = "4.5.2", features = ["cargo"] }
csv = "1.3.0"
serde_json = "1.0.114"

View file

@ -1,4 +1,6 @@
use std::process::{Command, Output};
use ansi_term::Color;
mod args;
#[derive(Debug, Clone)]
@ -27,7 +29,9 @@ impl IterationOutput {
fn print_text(&self) {
println!(
"Commit [{}] ({}): {}",
self.commit.hash, self.commit.datetime, self.commit.name
Color::Green.paint(&self.commit.hash),
Color::Purple.paint(&self.commit.datetime),
Color::Blue.paint(&self.commit.name)
);
println!("{}", self.stdout);
if !self.stderr.is_empty() {
@ -169,7 +173,6 @@ fn main() {
if is_repository_clean(repo) || allow_dirty {
let commits = get_commit_list(repo).unwrap();
for commit in commits {
// todo : add colors
out.push(commit.run_command(&command));
}
checkout(repo, "main").unwrap();