diff --git a/Cargo.toml b/Cargo.toml index fb38bfa..db5859c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +colored = "2.0.0" diff --git a/src/main.rs b/src/main.rs index 5f9e05e..135cdf4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ mod ip; // declare that there is a ip.rs module needed by this project use ip::Ip; // import the Ip type from the ip module +use colored::*; // for fancy colors :) fn main() { let Some(arg) = std::env::args().nth(1) else { @@ -15,10 +16,10 @@ fn main() { let nbr = u32::from(&ip); - println!("Canonical: {}", ip); - println!("Debug....: {:?}", ip); - println!("Binary...: {:032b}", nbr); - println!("Hexa.....: 0x{:x}", nbr); + println!("Canonical: {}", ip.to_string().blue().bold()); + println!("Debug....: {}", format!("{:?}", ip).green()); + println!("Binary...: {}", format!("{:032b}", nbr).red()); + println!("Hexa.....: {}", format!("0x{:x}", nbr).yellow()); let comment = match ip { Ip::V4([127, 0, 0, 1]) => "This is you.", @@ -26,6 +27,6 @@ fn main() { Ip::V4([10,_,_,_]) => "This is a big local area network", _ => "Nothing special to say about this address" }; - println!("{}", comment); + println!("{}", comment.dimmed()); }