Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Problem: (CRO-500) client-cli fails to compile with cli-table 0.2
Browse files Browse the repository at this point in the history
Solution: Updated `cli-table` version to 0.2 and made necessary code changes
  • Loading branch information
devashishdxt committed Oct 21, 2019
1 parent eb67486 commit bc919f2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
60 changes: 32 additions & 28 deletions client-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
&<DateTime<Local>>::from(DateTime::<Utc>::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(
&<DateTime<Local>>::from(DateTime::<Utc>::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(())
Expand Down Expand Up @@ -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!")
Expand Down

0 comments on commit bc919f2

Please sign in to comment.