comfy-table instead of prettytable-rs

This commit is contained in:
Daniel Karzel 2021-07-06 14:19:15 +10:00 committed by Thomas Eizinger
parent b4fafeba6b
commit f45cde84ab
No known key found for this signature in database
GPG key ID: 651AC83A6C6C8B96
4 changed files with 71 additions and 132 deletions

View file

@ -13,10 +13,10 @@
#![allow(non_snake_case)]
use anyhow::{bail, Context, Result};
use comfy_table::Table;
use libp2p::core::multiaddr::Protocol;
use libp2p::core::Multiaddr;
use libp2p::Swarm;
use prettytable::{row, Table};
use std::env;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
use std::sync::Arc;
@ -37,9 +37,6 @@ use swap::{asb, bitcoin, kraken, monero, tor};
use tracing::{debug, info, warn};
use tracing_subscriber::filter::LevelFilter;
#[macro_use]
extern crate prettytable;
const DEFAULT_WALLET_NAME: &str = "asb-wallet";
#[tokio::main]
@ -194,14 +191,13 @@ async fn main() -> Result<()> {
Command::History => {
let mut table = Table::new();
table.add_row(row!["SWAP ID", "STATE"]);
table.set_header(vec!["SWAP ID", "STATE"]);
for (swap_id, state) in db.all_alice()? {
table.add_row(row![swap_id, state]);
table.add_row(vec![swap_id.to_string(), state.to_string()]);
}
// Print the table to stdout
table.printstd();
println!("{}", table);
}
Command::WithdrawBtc { amount, address } => {
let bitcoin_wallet = init_bitcoin_wallet(&config, &seed, env_config).await?;

View file

@ -13,7 +13,7 @@
#![allow(non_snake_case)]
use anyhow::{bail, Context, Result};
use prettytable::{row, Table};
use comfy_table::Table;
use qrcode::render::unicode;
use qrcode::QrCode;
use std::cmp::min;
@ -38,9 +38,6 @@ use tracing::{debug, error, info, warn};
use url::Url;
use uuid::Uuid;
#[macro_use]
extern crate prettytable;
#[tokio::main]
async fn main() -> Result<()> {
let Arguments {
@ -144,14 +141,13 @@ async fn main() -> Result<()> {
let mut table = Table::new();
table.add_row(row!["SWAP ID", "STATE"]);
table.set_header(vec!["SWAP ID", "STATE"]);
for (swap_id, state) in db.all_bob()? {
table.add_row(row![swap_id, state]);
table.add_row(vec![swap_id.to_string(), state.to_string()]);
}
// Print the table to stdout
table.printstd();
println!("{}", table);
}
Command::Resume {
swap_id,