Skip to content

Commit fba61a3

Browse files
committed
Colorify the output
1 parent 1db999c commit fba61a3

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

Cargo.lock

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ edition = "2018"
88

99
[dependencies]
1010
serde_json = "1.0.41"
11-
maplit = "1.0.2"
11+
maplit = "1.0.2"
12+
colored = "1.9.0"

src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
use colored::*;
12
use serde_json;
23
use serde_json::Map;
34
use serde_json::Value;
45
use std::collections::HashMap;
56
use std::collections::HashSet;
67
use std::env;
7-
use std::fmt;
88
use std::fs;
99

1010
fn main() {
@@ -47,7 +47,7 @@ fn display_output(result: Mismatch) {
4747
result.left_only_keys.absolute_keys(&mut keys, None);
4848
println!("Extra on left:");
4949
for key in keys {
50-
println!("{}", key);
50+
println!("{}", key.red().bold());
5151
}
5252
}
5353
KeyNode::Value(_, _) => (), // TODO left_only_keys should never be Value type => Throw an error
@@ -59,7 +59,7 @@ fn display_output(result: Mismatch) {
5959
result.right_only_keys.absolute_keys(&mut keys, None);
6060
println!("Extra on right:");
6161
for key in keys {
62-
println!("{}", key);
62+
println!("{}", key.green().bold());
6363
}
6464
}
6565
KeyNode::Value(_, _) => (), // TODO right_only_keys should never be Value type => Throw an error
@@ -88,7 +88,7 @@ impl KeyNode {
8888
match self {
8989
KeyNode::Nil => keys.push(nil_key(key_from_root)),
9090
KeyNode::Value(a, b) => {
91-
keys.push(format!("{} [ {} :: {} ]", val_key(key_from_root), a, b))
91+
keys.push(format!("{} [ {} :: {} ]", val_key(key_from_root), a.to_string().blue().bold(), b.to_string().cyan().bold()))
9292
}
9393
KeyNode::Node(map) => {
9494
for (key, value) in map {

0 commit comments

Comments
 (0)