Add color to status
This commit is contained in:
parent
672549a86d
commit
f506835b53
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -181,6 +181,16 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.17"
|
||||
@ -455,6 +465,12 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.170"
|
||||
@ -575,6 +591,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"base64",
|
||||
"clap",
|
||||
"colored",
|
||||
"env_logger",
|
||||
"http",
|
||||
"log",
|
||||
|
@ -11,4 +11,5 @@ http = { version = "1.2.0" }
|
||||
anyhow = "1.0.97"
|
||||
url = "2.5.4"
|
||||
base64 = "0.22.1"
|
||||
sha256 = "1.6.0"
|
||||
sha256 = "1.6.0"
|
||||
colored = "2"
|
10
src/main.rs
10
src/main.rs
@ -6,6 +6,7 @@ use sha256::{digest, Sha256Digest};
|
||||
use url::Url;
|
||||
use base64::prelude::*;
|
||||
use base64::engine::general_purpose::URL_SAFE as BASE64_URL_URL_SAFE;
|
||||
use colored::Colorize;
|
||||
|
||||
/// Simple SCEP parser program
|
||||
#[derive(Parser, Debug)]
|
||||
@ -141,13 +142,18 @@ fn main() {
|
||||
_ => panic!("Unsupported operation {}!", operation),
|
||||
};
|
||||
|
||||
let status = match response.status().as_u16() {
|
||||
100..=199=> response.status().as_u16().to_string().blue(),
|
||||
200..=299 => response.status().as_u16().to_string().green(),
|
||||
400..=999 => response.status().as_u16().to_string().red(),
|
||||
_ => response.status().as_u16().to_string().white().on_red(),
|
||||
};
|
||||
let date = response.headers().get("Date").unwrap().to_str().unwrap();
|
||||
|
||||
let sha_req = sha256::digest(request.body()).chars().take(10).collect::<String>();
|
||||
let sha_res = sha256::digest(response.body()).chars().take(10).collect::<String>();
|
||||
|
||||
// TODO : add color
|
||||
println!("{date} - {} - {op:?}\t - Req: {sha_req}\t - Res: {sha_res}", response.status().as_u16());
|
||||
println!("{date} - {status} - {op:?}\t - Req: {sha_req}\t - Res: {sha_res}");
|
||||
|
||||
// Parse details about PKIOperation request
|
||||
// https://www.rfc-editor.org/rfc/rfc8894.html#section-4.3
|
||||
|
Loading…
x
Reference in New Issue
Block a user