Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colors in CLI for wallet_info #3662

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions massa-client/src/cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ pub enum ListOperation {
/// Used to have a shinny json output
/// TODO re-factor me
#[derive(Debug, Serialize)]
struct ExtendedWalletEntry {
pub (crate) struct ExtendedWalletEntry {
/// the keypair
pub keypair: KeyPair,
/// address and balance information
Expand All @@ -362,7 +362,7 @@ impl Display for ExtendedWalletEntry {
/// Aggregation of the local, with some useful information as the balance, etc
/// to be printed by the client.
#[derive(Debug, Serialize)]
pub struct ExtendedWallet(PreHashMap<Address, ExtendedWalletEntry>);
pub struct ExtendedWallet(pub (crate) PreHashMap<Address, ExtendedWalletEntry>);

impl ExtendedWallet {
/// Reorganize everything into an extended wallet
Expand Down
32 changes: 31 additions & 1 deletion massa-client/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,37 @@ impl Output for Wallet {

impl Output for ExtendedWallet {
fn pretty_print(&self) {
println!("{}", self);
if self.0.is_empty() {
client_warning!("your wallet does not contain any key, use 'wallet_generate_secret_key' to generate a new key and add it to your wallet");
}
println!("{}", Style::Separator.style("====="));
for entry in self.0.values() {
if entry.show_keys {
println!("Secret key: {}", Style::Secret.style(&entry.keypair));
println!("Public key: {}", Style::Wallet.style(entry.keypair.get_public_key()));
}
println!("Address: {} (thread {}):",
Style::Wallet.style(entry.address_info.address),
Style::Protocol.style(entry.address_info.thread),
);
println!(
"\tBalance: {}={}, {}={}",
Style::Finished.style("final"),
Style::Coins.style(entry.address_info.final_balance),
Style::Pending.style("candidate"),
Style::Coins.style(entry.address_info.candidate_balance),
);
println!(
"\tRolls: {}={}, {}={}, {}={}",
Style::Good.style("active"),
Style::Protocol.style(entry.address_info.active_rolls),
Style::Finished.style("final"),
Style::Protocol.style(entry.address_info.final_rolls),
Style::Pending.style("candidate"),
Style::Protocol.style(entry.address_info.candidate_rolls),
);
println!("{}", Style::Separator.style("====="));
}
}
}

Expand Down