From 05896705a324711c0ba76e4271de3a740c2949e0 Mon Sep 17 00:00:00 2001 From: jmunoz Date: Mon, 27 Nov 2023 11:04:48 -0300 Subject: [PATCH] replace tabled with no std alt --- Cargo.toml | 2 +- src/cli/account.rs | 37 ++++++++++++++++++------------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb1a0cef4..e49d2997a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ rusqlite_migration = { version = "1.0" } rand = { version="0.8.5" } serde = {version="1.0", features = ["derive"]} serde_json = { version = "1.0", features = ["raw_value"] } -tabled = "0.14.0" +cli-table = "0.4.7" [dev-dependencies] ctor = "0.2.5" diff --git a/src/cli/account.rs b/src/cli/account.rs index d0705b649..0944f8ff9 100644 --- a/src/cli/account.rs +++ b/src/cli/account.rs @@ -1,10 +1,10 @@ use clap::Parser; +use cli_table::{print_stdout, Cell, Style, Table}; use crypto::{dsa::rpo_falcon512::KeyPair, Felt}; use miden_client::{Client, ClientConfig}; use miden_lib::{faucets, AuthScheme}; use objects::{accounts::AccountType, assets::TokenSymbol}; use rand::Rng; -use tabled::{builder::Builder, settings::Style}; // ACCOUNT COMMAND // ================================================================================================ @@ -77,27 +77,26 @@ fn list_accounts() -> Result<(), String> { let client = Client::new(ClientConfig::default()).map_err(|err| err.to_string())?; let accounts = client.get_accounts().map_err(|err| err.to_string())?; - let mut builder = Builder::new(); - builder.push_record([ - "account id", - "code root", - "vault root", - "storage root", - "nonce", - ]); - + let mut rows = vec![]; for acct in accounts { - builder.push_record([ - &acct.id().to_string(), - &acct.code_root().to_string(), - &acct.vault_root().to_string(), - &acct.storage_root().to_string(), - &acct.nonce().to_string(), - ]); + let mut row = vec![]; + row.push(acct.id().cell()); + row.push(acct.code_root().cell()); + row.push(acct.vault_root().cell()); + row.push(acct.storage_root().cell()); + row.push(acct.nonce().cell()); + rows.push(row); } - let table = builder.build().with(Style::modern()).to_string(); - println!("{}", table); + let table = rows.table().title(vec![ + "account id".cell().bold(true), + "code root".cell().bold(true), + "vault root".cell().bold(true), + "storage root".cell().bold(true), + "nonce".cell().bold(true), + ]); + + print_stdout(table).map_err(|err| err.to_string())?; Ok(()) }