add colors :p
This commit is contained in:
parent
58a9e8e2b6
commit
977d740ef0
@ -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"
|
||||
|
11
src/main.rs
11
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());
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user