From bc919f286f38cbeb334d8a59acb69065affae6e6 Mon Sep 17 00:00:00 2001 From: Devashish Dixit Date: Mon, 21 Oct 2019 14:01:30 +0800 Subject: [PATCH] Problem: (CRO-500) client-cli fails to compile with cli-table 0.2 Solution: Updated `cli-table` version to 0.2 and made necessary code changes --- Cargo.lock | 6 ++-- client-cli/Cargo.toml | 2 +- client-cli/src/command.rs | 60 +++++++++++++++++++++------------------ 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 004bf7acf..04223e08f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,7 @@ dependencies = [ [[package]] name = "cli-table" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -376,7 +376,7 @@ version = "0.1.0" dependencies = [ "chain-core 0.1.0", "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "cli-table 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cli-table 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "client-common 0.1.0", "client-core 0.1.0", "client-network 0.1.0", @@ -3133,7 +3133,7 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e8493056968583b0193c1bb04d6f7684586f3726992d6c573261941a895dbd68" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum cli-table 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5550760a096565fda0086e12dfc9ff0c50fd3147b2f571eb40c5b126bf07eb97" +"checksum cli-table 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6fe7bde9ea2c89a08ae0f5b75de12a5afbedb424dc09d9f58a9d850a348f60e0" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmac 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4a435124bcc292eba031f1f725d7abacdaf13cbf9f935450e8c45aa9e96cad" "checksum cmake 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "81fb25b677f8bf1eb325017cb6bb8452f87969db0fedb4f757b297bee78a7c62" diff --git a/client-cli/Cargo.toml b/client-cli/Cargo.toml index fefc4dfa2..e82992dce 100644 --- a/client-cli/Cargo.toml +++ b/client-cli/Cargo.toml @@ -18,4 +18,4 @@ chrono = "0.4" pbr = "1.0" log = "0.4.8" env_logger = "0.7.1" -cli-table = "0.1" +cli-table = "0.2" diff --git a/client-cli/src/command.rs b/client-cli/src/command.rs index de591a285..0b9e234ad 100644 --- a/client-cli/src/command.rs +++ b/client-cli/src/command.rs @@ -6,7 +6,8 @@ use std::sync::mpsc::channel; use std::thread; use chrono::{DateTime, Local, NaiveDateTime, Utc}; -use cli_table::{Cell, CellFormat, Color, Justify, Row, Table}; +use cli_table::format::{CellFormat, Color, Justify}; +use cli_table::{Cell, Row, Table}; use hex::encode; use pbr::ProgressBar; use quest::success; @@ -217,33 +218,36 @@ impl Command { let bold = CellFormat::builder().bold(true).build(); let justify_right = CellFormat::builder().justify(Justify::Right).build(); - let table = Table::new(vec![ - Row::new(vec![ - Cell::new("Nonce", bold), - Cell::new(&staked_state.nonce, justify_right), - ]), - Row::new(vec![ - Cell::new("Bonded", bold), - Cell::new(&staked_state.bonded, justify_right), - ]), - Row::new(vec![ - Cell::new("Unbonded", bold), - Cell::new(&staked_state.unbonded, justify_right), - ]), - Row::new(vec![ - Cell::new("Unbonded From", bold), - Cell::new( - &>::from(DateTime::::from_utc( - NaiveDateTime::from_timestamp(staked_state.unbonded_from, 0), - Utc, - )), - Default::default(), - ), - ]), - ]); + let table = Table::new( + vec![ + Row::new(vec![ + Cell::new("Nonce", bold), + Cell::new(&staked_state.nonce, justify_right), + ]), + Row::new(vec![ + Cell::new("Bonded", bold), + Cell::new(&staked_state.bonded, justify_right), + ]), + Row::new(vec![ + Cell::new("Unbonded", bold), + Cell::new(&staked_state.unbonded, justify_right), + ]), + Row::new(vec![ + Cell::new("Unbonded From", bold), + Cell::new( + &>::from(DateTime::::from_utc( + NaiveDateTime::from_timestamp(staked_state.unbonded_from, 0), + Utc, + )), + Default::default(), + ), + ]), + ], + Default::default(), + ); table - .print_std() + .print_stdout() .chain(|| (ErrorKind::IoError, "Unable to print table"))?; Ok(()) @@ -317,10 +321,10 @@ impl Command { ])); } - let table = Table::new(rows); + let table = Table::new(rows, Default::default()); table - .print_std() + .print_stdout() .chain(|| (ErrorKind::IoError, "Unable to print table"))?; } else { success("No history found!")