summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZicklag <zicklag@katharostech.com>2019-10-07 17:50:57 -0500
committerZicklag <zicklag@katharostech.com>2019-10-07 17:50:57 -0500
commit4d8a7ea913f78a7bd257d2a16fc48a1d29a794e1 (patch)
treef803d36b9fc7169c31f4bcb33c71b5d6449addf2
parent50a505e66f44f0efcfc0fa1390fcc889ab8dcd01 (diff)
downloadroughenough-4d8a7ea913f78a7bd257d2a16fc48a1d29a794e1.zip
Add Verbose and JSON Options to Client
-rw-r--r--src/bin/roughenough-client.rs33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/bin/roughenough-client.rs b/src/bin/roughenough-client.rs
index a8cc28f..877e433 100644
--- a/src/bin/roughenough-client.rs
+++ b/src/bin/roughenough-client.rs
@@ -222,6 +222,14 @@ fn main() {
.required(true)
.help("The Roughtime server port to connect to")
.takes_value(true))
+ .arg(Arg::with_name("verbose")
+ .short("v")
+ .long("verbose")
+ .help("Print more output"))
+ .arg(Arg::with_name("json")
+ .short("j")
+ .long("json")
+ .help("Print output in JSON"))
.arg(Arg::with_name("public-key")
.short("p")
.long("public-key")
@@ -256,6 +264,8 @@ fn main() {
let host = matches.value_of("host").unwrap();
let port = value_t_or_exit!(matches.value_of("port"), u16);
+ let verbose = matches.is_present("verbose");
+ let json = matches.is_present("json");
let num_requests = value_t_or_exit!(matches.value_of("num-requests"), u16) as usize;
let time_format = matches.value_of("time-format").unwrap();
let stress = matches.is_present("stress");
@@ -264,7 +274,9 @@ fn main() {
.map(|pkey| hex::decode(pkey).expect("Error parsing public key!"));
let out = matches.value_of("output");
- println!("Requesting time from: {:?}:{:?}", host, port);
+ if verbose {
+ println!("Requesting time from: {:?}:{:?}", host, port);
+ }
let addr = (host, port).to_socket_addrs().unwrap().next().unwrap();
@@ -312,10 +324,21 @@ fn main() {
let out = spec.format(time_format).to_string();
let verify_str = if verified { "Yes" } else { "No" };
- println!(
- "Received time from server: midpoint={:?}, radius={:?}, verified={} (merkle_index={})",
- out, radius, verify_str, index
- );
+ if verbose {
+ println!(
+ "Received time from server: midpoint={:?}, radius={:?}, verified={} (merkle_index={})",
+ out, radius, verify_str, index
+ );
+ }
+
+ if json {
+ println!(
+ r#"{{ "midpoint": {:?}, "radius": {:?}, "verified": {}, "merkle_index": {} }}"#,
+ out, radius, verified, index
+ );
+ } else {
+ println!("{}", out);
+ }
}
}