From 27972393968c74ae27a4769421d32e53a56cd3e4 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 14:35:02 +0100 Subject: [PATCH 01/16] Add Style enum to get generic styling on the CLI Signed-off-by: Litchi Pi --- massa-client/src/repl.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/massa-client/src/repl.rs b/massa-client/src/repl.rs index 929ab2d3320..2a489b1682f 100644 --- a/massa-client/src/repl.rs +++ b/massa-client/src/repl.rs @@ -224,6 +224,36 @@ impl Completer for MassaCompleter { } } +pub enum Style { + Id, + Pending, + Finished, + Good, + Bad, + Unknown, + Block, + Signature, + Address, + Fee, +} + +impl Style { + fn style(&self, msg: T) -> console::StyledObject { + style(msg.to_string()).color256(match self { + Style::Id => 175, + Style::Pending => 172, + Style::Finished => 105, + Style::Good => 118, + Style::Bad => 160, + Style::Unknown => 248, + Style::Block => 158, + Style::Signature => 220, + Style::Address => 147, + Style::Fee => 55, + }) + } +} + pub trait Output: Serialize { fn pretty_print(&self); } From a2265b8ab9968a050c177e4402d7b2093c0732ce Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 14:52:11 +0100 Subject: [PATCH 02/16] Add comments on the generic styles Signed-off-by: Litchi Pi --- massa-client/src/repl.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/massa-client/src/repl.rs b/massa-client/src/repl.rs index 2a489b1682f..c894918c403 100644 --- a/massa-client/src/repl.rs +++ b/massa-client/src/repl.rs @@ -225,14 +225,22 @@ impl Completer for MassaCompleter { } pub enum Style { + /// Any information that identifies an element Id, + /// If a process is ongoing, not final, will change in the future Pending, + /// If a process is finished, fixed, and won't evolve in the future Finished, + /// Good things in general, success of an operation Good, + /// Bad things in general, failure of an operation Bad, + /// For any information that is unknown Unknown, Block, + /// For cryptographic signature Signature, + /// For addresses or public keys Address, Fee, } From aa08a5a3c0db897fe70ef4c9f7acb4a523774634 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 14:52:54 +0100 Subject: [PATCH 03/16] Rename 'fee' generic style to 'coins', lighten its color Signed-off-by: Litchi Pi --- massa-client/src/repl.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/massa-client/src/repl.rs b/massa-client/src/repl.rs index c894918c403..3683ce5ed7f 100644 --- a/massa-client/src/repl.rs +++ b/massa-client/src/repl.rs @@ -237,12 +237,14 @@ pub enum Style { Bad, /// For any information that is unknown Unknown, + /// Any amount of Massa coin displayed + Coins, + /// Any information concerning a block of the blockchain Block, /// For cryptographic signature Signature, /// For addresses or public keys Address, - Fee, } impl Style { @@ -254,10 +256,10 @@ impl Style { Style::Good => 118, Style::Bad => 160, Style::Unknown => 248, + Style::Coins => 99, Style::Block => 158, Style::Signature => 220, Style::Address => 147, - Style::Fee => 55, }) } } From 6bb6f1a830d4c05030b1f666e1cea16fd24440c5 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 15:27:09 +0100 Subject: [PATCH 04/16] Split display-specific function into a separate module Signed-off-by: Litchi Pi --- massa-client/src/cmds.rs | 29 ++-- massa-client/src/display.rs | 268 ++++++++++++++++++++++++++++++++++++ massa-client/src/main.rs | 1 + massa-client/src/repl.rs | 252 +-------------------------------- 4 files changed, 282 insertions(+), 268 deletions(-) create mode 100644 massa-client/src/display.rs diff --git a/massa-client/src/cmds.rs b/massa-client/src/cmds.rs index 26e7445bd6a..076ec7e149c 100644 --- a/massa-client/src/cmds.rs +++ b/massa-client/src/cmds.rs @@ -1,6 +1,7 @@ // Copyright (c) 2022 MASSA LABS -use crate::repl::Output; +use crate::display::Output; +use crate::{client_warning, rpc_error}; use anyhow::{anyhow, bail, Result}; use console::style; use massa_api_exports::{ @@ -334,26 +335,6 @@ pub enum ListOperation { Remove, } -/// Display the help of all commands -pub(crate) fn help() { - println!("HELP of Massa client (list of available commands):"); - Command::iter().map(|c| c.help()).collect() -} - -/// bail a shinny RPC error -macro_rules! rpc_error { - ($e:expr) => { - bail!("check if your node is running: {}", $e) - }; -} - -/// print a yellow warning -macro_rules! client_warning { - ($e:expr) => { - println!("{}: {}", style("WARNING").yellow(), $e) - }; -} - /// Used to have a shinny json output /// TODO re-factor me #[derive(Debug, Serialize)] @@ -1449,3 +1430,9 @@ where Ok(None) } } + +/// Display the help of all commands +pub fn help() { + println!("HELP of Massa client (list of available commands):"); + Command::iter().map(|c| c.help()).collect() +} diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs new file mode 100644 index 00000000000..4c8ece1bafa --- /dev/null +++ b/massa-client/src/display.rs @@ -0,0 +1,268 @@ +// Copyright (c) 2023 MASSA LABS + +use crate::cmds::ExtendedWallet; +use console::style; +use erased_serde::{Serialize, Serializer}; +use massa_api_exports::{ + address::AddressInfo, block::BlockInfo, datastore::DatastoreEntryOutput, + endorsement::EndorsementInfo, execution::ExecuteReadOnlyResponse, node::NodeStatus, + operation::OperationInfo, +}; +use massa_models::composite::PubkeySig; +use massa_models::output_event::SCOutputEvent; +use massa_models::prehash::PreHashSet; +use massa_models::{address::Address, operation::OperationId}; +use massa_signature::{KeyPair, PublicKey}; +use massa_wallet::Wallet; +use std::str; +use std::net::IpAddr; + +#[macro_export] +macro_rules! massa_fancy_ascii_art_logo { + () => { + println!( + "{}\n{}\n{}\n{}\n{}\n", + style("███ ███ █████ ███████ ███████ █████ ").color256(160), + style("████ ████ ██ ██ ██ ██ ██ ██").color256(161), + style("██ ████ ██ ███████ ███████ ███████ ███████").color256(162), + style("██ ██ ██ ██ ██ ██ ██ ██ ██").color256(163), + style("██ ██ ██ ██ ███████ ███████ ██ ██").color256(164) + ); + }; +} + +#[macro_export] +/// bail a shinny RPC error +macro_rules! rpc_error { + ($e:expr) => { + bail!("check if your node is running: {}", $e) + }; +} + +#[macro_export] +/// print a yellow warning +macro_rules! client_warning { + ($e:expr) => { + println!("{}: {}", style("WARNING").yellow(), $e) + }; +} + +pub enum Style { + /// Any information that identifies an element + Id, + /// If a process is ongoing, not final, will change in the future + Pending, + /// If a process is finished, fixed, and won't evolve in the future + Finished, + /// Good things in general, success of an operation + Good, + /// Bad things in general, failure of an operation + Bad, + /// For any information that is unknown + Unknown, + /// Any amount of Massa coin displayed + Coins, + /// Any information concerning a block of the blockchain + Block, + /// For cryptographic signature + Signature, + /// For addresses or public keys + Address, + /// For any secret information + Secret, +} + +impl Style { + fn style(&self, msg: T) -> console::StyledObject { + style(msg.to_string()).color256(match self { + Style::Id => 175, + Style::Pending => 172, + Style::Finished => 105, + Style::Good => 118, + Style::Bad => 160, + Style::Unknown => 248, + Style::Coins => 99, + Style::Block => 158, + Style::Signature => 220, + Style::Address => 147, + Style::Secret => 64, + }) + } +} + +pub trait Output: Serialize { + fn pretty_print(&self); +} + +impl dyn Output { + pub(crate) fn stdout_json(&self) -> anyhow::Result<()> { + let json = &mut serde_json::Serializer::new(std::io::stdout()); + let mut format: Box = Box::new(::erase(json)); + self.erased_serialize(&mut format)?; + Ok(()) + } +} + +impl Output for Wallet { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for ExtendedWallet { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for Vec<(Address, PublicKey)> { + fn pretty_print(&self) { + match self.len() { + 1 => println!("{}", self[0].1), + _ => { + for address_pubkey in self { + println!("Address: {}", address_pubkey.0); + println!("Public key: {}", address_pubkey.1); + println!(); + } + } + } + } +} + +impl Output for Vec<(Address, KeyPair)> { + fn pretty_print(&self) { + match self.len() { + 1 => println!("{}", self[0].1), + _ => { + for address_seckey in self { + println!("Address: {}", address_seckey.0); + println!("Secret key: {}", address_seckey.1); + println!(); + } + } + } + } +} + +impl Output for () { + fn pretty_print(&self) {} +} + +impl Output for String { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for &str { + fn pretty_print(&self) { + println!("{}", self) + } +} + +impl Output for NodeStatus { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for BlockInfo { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for PreHashSet
{ + fn pretty_print(&self) { + println!( + "{}", + self.iter() + .fold("".to_string(), |acc, a| format!("{}{}\n", acc, a)) + ) + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for address_info in self { + println!("{}", address_info); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for data_entry in self { + println!("{}", data_entry); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for endorsement_info in self { + println!("{}", endorsement_info); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for ips in self { + println!("{}", ips); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for operation_info in self { + println!("{}", operation_info); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for block_info in self { + println!("{}", block_info); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for operation_id in self { + println!("{}", operation_id); + } + } +} + +impl Output for Vec
{ + fn pretty_print(&self) { + for addr in self { + println!("{}", addr); + } + } +} + +impl Output for Vec { + fn pretty_print(&self) { + for addr in self { + println!("{}", addr); + } + } +} + +impl Output for PubkeySig { + fn pretty_print(&self) { + println!("{}", self); + } +} + +impl Output for ExecuteReadOnlyResponse { + fn pretty_print(&self) { + println!("{}", self); + } +} diff --git a/massa-client/src/main.rs b/massa-client/src/main.rs index 2ccf3ba48cd..4224da42cf4 100644 --- a/massa-client/src/main.rs +++ b/massa-client/src/main.rs @@ -20,6 +20,7 @@ use structopt::StructOpt; mod cmds; mod repl; mod settings; +mod display; #[cfg(test)] pub mod tests; diff --git a/massa-client/src/repl.rs b/massa-client/src/repl.rs index 3683ce5ed7f..1dd0a236567 100644 --- a/massa-client/src/repl.rs +++ b/massa-client/src/repl.rs @@ -1,48 +1,23 @@ // Copyright (c) 2022 MASSA LABS use crate::ask_password; -use crate::cmds::{Command, ExtendedWallet}; +use crate::cmds::Command; use crate::settings::SETTINGS; -use anyhow::Result; -use console::style; -use erased_serde::{Serialize, Serializer}; -use massa_api_exports::{ - address::AddressInfo, block::BlockInfo, datastore::DatastoreEntryOutput, - endorsement::EndorsementInfo, execution::ExecuteReadOnlyResponse, node::NodeStatus, - operation::OperationInfo, -}; -use massa_models::composite::PubkeySig; -use massa_models::output_event::SCOutputEvent; -use massa_models::prehash::PreHashSet; -use massa_models::{address::Address, operation::OperationId}; +use crate::massa_fancy_ascii_art_logo; use massa_sdk::Client; -use massa_signature::{KeyPair, PublicKey}; use massa_wallet::Wallet; -use rustyline::completion::{Completer, FilenameCompleter, Pair}; +use anyhow::Result; +use console::style; use rustyline::error::ReadlineError; use rustyline::validate::MatchingBracketValidator; use rustyline::{CompletionType, Config, Editor}; use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator}; +use rustyline::completion::{Completer, FilenameCompleter, Pair}; use std::env; -use std::net::IpAddr; use std::path::Path; -use std::str; use strum::IntoEnumIterator; use strum::ParseError; -macro_rules! massa_fancy_ascii_art_logo { - () => { - println!( - "{}\n{}\n{}\n{}\n{}\n", - style("███ ███ █████ ███████ ███████ █████ ").color256(160), - style("████ ████ ██ ██ ██ ██ ██ ██").color256(161), - style("██ ████ ██ ███████ ███████ ███████ ███████").color256(162), - style("██ ██ ██ ██ ██ ██ ██ ██ ██").color256(163), - style("██ ██ ██ ██ ███████ ███████ ██ ██").color256(164) - ); - }; -} - fn group_parameters(parameters: Vec) -> Vec { let mut new_parameters = Vec::new(); let mut has_opening_simple_quote = false; @@ -223,220 +198,3 @@ impl Completer for MassaCompleter { } } } - -pub enum Style { - /// Any information that identifies an element - Id, - /// If a process is ongoing, not final, will change in the future - Pending, - /// If a process is finished, fixed, and won't evolve in the future - Finished, - /// Good things in general, success of an operation - Good, - /// Bad things in general, failure of an operation - Bad, - /// For any information that is unknown - Unknown, - /// Any amount of Massa coin displayed - Coins, - /// Any information concerning a block of the blockchain - Block, - /// For cryptographic signature - Signature, - /// For addresses or public keys - Address, -} - -impl Style { - fn style(&self, msg: T) -> console::StyledObject { - style(msg.to_string()).color256(match self { - Style::Id => 175, - Style::Pending => 172, - Style::Finished => 105, - Style::Good => 118, - Style::Bad => 160, - Style::Unknown => 248, - Style::Coins => 99, - Style::Block => 158, - Style::Signature => 220, - Style::Address => 147, - }) - } -} - -pub trait Output: Serialize { - fn pretty_print(&self); -} - -impl dyn Output { - pub(crate) fn stdout_json(&self) -> anyhow::Result<()> { - let json = &mut serde_json::Serializer::new(std::io::stdout()); - let mut format: Box = Box::new(::erase(json)); - self.erased_serialize(&mut format)?; - Ok(()) - } -} - -impl Output for Wallet { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for ExtendedWallet { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for Vec<(Address, PublicKey)> { - fn pretty_print(&self) { - match self.len() { - 1 => println!("{}", self[0].1), - _ => { - for address_pubkey in self { - println!("Address: {}", address_pubkey.0); - println!("Public key: {}", address_pubkey.1); - println!(); - } - } - } - } -} - -impl Output for Vec<(Address, KeyPair)> { - fn pretty_print(&self) { - match self.len() { - 1 => println!("{}", self[0].1), - _ => { - for address_seckey in self { - println!("Address: {}", address_seckey.0); - println!("Secret key: {}", address_seckey.1); - println!(); - } - } - } - } -} - -impl Output for () { - fn pretty_print(&self) {} -} - -impl Output for String { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for &str { - fn pretty_print(&self) { - println!("{}", self) - } -} - -impl Output for NodeStatus { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for BlockInfo { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for PreHashSet
{ - fn pretty_print(&self) { - println!( - "{}", - self.iter() - .fold("".to_string(), |acc, a| format!("{}{}\n", acc, a)) - ) - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for address_info in self { - println!("{}", address_info); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for data_entry in self { - println!("{}", data_entry); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for endorsement_info in self { - println!("{}", endorsement_info); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for ips in self { - println!("{}", ips); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for operation_info in self { - println!("{}", operation_info); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for block_info in self { - println!("{}", block_info); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for operation_id in self { - println!("{}", operation_id); - } - } -} - -impl Output for Vec
{ - fn pretty_print(&self) { - for addr in self { - println!("{}", addr); - } - } -} - -impl Output for Vec { - fn pretty_print(&self) { - for addr in self { - println!("{}", addr); - } - } -} - -impl Output for PubkeySig { - fn pretty_print(&self) { - println!("{}", self); - } -} - -impl Output for ExecuteReadOnlyResponse { - fn pretty_print(&self) { - println!("{}", self); - } -} From 22c6c2a124ba4664963b88380a2fd82e674ff30f Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 15:33:11 +0100 Subject: [PATCH 05/16] Add separator generic style element Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 4c8ece1bafa..1066627e2af 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -70,6 +70,8 @@ pub enum Style { Address, /// For any secret information Secret, + /// To separate some informations on the screen by barely visible characters + Separator, } impl Style { @@ -86,6 +88,7 @@ impl Style { Style::Signature => 220, Style::Address => 147, Style::Secret => 64, + Style::Separator => 239, }) } } From 5d9949818a5afdd783537dd8f6f95a80e57e9a57 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 15:51:49 +0100 Subject: [PATCH 06/16] Rename Style::Address to Style::Wallet, add Style::Protocol Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 1066627e2af..cdfd73fd76d 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -62,12 +62,14 @@ pub enum Style { Unknown, /// Any amount of Massa coin displayed Coins, + /// Any information related to the protocol, staking, peers and the consensus + Protocol, /// Any information concerning a block of the blockchain Block, /// For cryptographic signature Signature, - /// For addresses or public keys - Address, + /// For any information related to the wallet, addresses or public keys + Wallet, /// For any secret information Secret, /// To separate some informations on the screen by barely visible characters @@ -84,9 +86,10 @@ impl Style { Style::Bad => 160, Style::Unknown => 248, Style::Coins => 99, + Style::Protocol => 226, Style::Block => 158, Style::Signature => 220, - Style::Address => 147, + Style::Wallet => 147, Style::Secret => 64, Style::Separator => 239, }) From 0fa3db90c7d0b30f7cfeec705e17ff8a979cbd14 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 16:12:15 +0100 Subject: [PATCH 07/16] Add comments with colors on each style, change some colors Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index cdfd73fd76d..7911d33bc06 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -79,19 +79,19 @@ pub enum Style { impl Style { fn style(&self, msg: T) -> console::StyledObject { style(msg.to_string()).color256(match self { - Style::Id => 175, - Style::Pending => 172, - Style::Finished => 105, - Style::Good => 118, - Style::Bad => 160, - Style::Unknown => 248, - Style::Coins => 99, - Style::Protocol => 226, - Style::Block => 158, - Style::Signature => 220, - Style::Wallet => 147, - Style::Secret => 64, - Style::Separator => 239, + Style::Id => 175, // #d787af + Style::Pending => 172, // #d78700 + Style::Finished => 81, // #5fd7ff + Style::Good => 112, // #87d700 + Style::Bad => 160, // #d70000 + Style::Unknown => 248, // #a8a8a8 + Style::Coins => 99, // #875fff + Style::Protocol => 184, // #d7d700 + Style::Block => 158, // #afffd7 + Style::Signature => 220, // #ffd700 + Style::Wallet => 193, // #d7ffaf + Style::Secret => 64, // #5f8700 + Style::Separator => 239, // #4e4e4e }) } } From c26eac33277dc29bdf8c4e757cc4daee27028452 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 16:15:54 +0100 Subject: [PATCH 08/16] Add colors in CLI for get_operations Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 7911d33bc06..604cb8ce522 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -223,8 +223,42 @@ impl Output for Vec { impl Output for Vec { fn pretty_print(&self) { - for operation_info in self { - println!("{}", operation_info); + for info in self { + println!("{}", style("==========").color256(237)); + print!("Operation {}", Style::Id.style(info.id)); + if info.in_pool { + print!(", {}", Style::Pending.style("in pool")); + } + if let Some(f) = info.is_operation_final { + print!(", operation is {}", if f { + Style::Finished.style("final") + } else { + Style::Pending.style("not final") + }); + } else { + print!(", finality {}", Style::Unknown.style("unknown")); + } + println!(", {}", match info.op_exec_status { + Some(true) => Style::Good.style("success"), + Some(false) => Style::Bad.style("failed"), + None => Style::Unknown.style("unknown status"), + }); + if info.in_blocks.is_empty() { + println!("{}", Style::Block.style("Not in any blocks")); + } else { + println!("In blocks:"); + for bid in info.in_blocks.iter() { + println!("\t- {}", Style::Block.style(bid)); + } + } + println!("Signature: {}", Style::Signature.style(info.operation.signature)); + println!("Creator pubkey: {}", + Style::Address.style(info.operation.content_creator_pub_key)); + println!("Creator address: {}", + Style::Address.style(info.operation.content_creator_address)); + println!("Fee: {}", Style::Coins.style(info.operation.content.fee)); + println!("Expire period: {}", Style::Pending.style(info.operation.content.expire_period)); + println!("Operation type: {}", Style::Id.style(&info.operation.content.op)); } } } From 73d5fbccdf2930e5ae2e2513c05582fc223ca97b Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Thu, 9 Mar 2023 08:42:49 +0100 Subject: [PATCH 09/16] Fix forgotten rename of Style in get_operations Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 604cb8ce522..2ba2c3d1d9a 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -253,9 +253,9 @@ impl Output for Vec { } println!("Signature: {}", Style::Signature.style(info.operation.signature)); println!("Creator pubkey: {}", - Style::Address.style(info.operation.content_creator_pub_key)); + Style::Wallet.style(info.operation.content_creator_pub_key)); println!("Creator address: {}", - Style::Address.style(info.operation.content_creator_address)); + Style::Wallet.style(info.operation.content_creator_address)); println!("Fee: {}", Style::Coins.style(info.operation.content.fee)); println!("Expire period: {}", Style::Pending.style(info.operation.content.expire_period)); println!("Operation type: {}", Style::Id.style(&info.operation.content.op)); From 9b2b70d9690a78232173f5ddb7dba0353afdb8e5 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Thu, 9 Mar 2023 09:23:46 +0100 Subject: [PATCH 10/16] Add colors in CLI for get_status Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 120 +++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 2ba2c3d1d9a..e9d5ffa0da3 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -11,7 +11,8 @@ use massa_api_exports::{ use massa_models::composite::PubkeySig; use massa_models::output_event::SCOutputEvent; use massa_models::prehash::PreHashSet; -use massa_models::{address::Address, operation::OperationId}; +use massa_models::{address::Address, operation::OperationId, config::CompactConfig}; +use massa_models::stats::{ConsensusStats, ExecutionStats, NetworkStats}; use massa_signature::{KeyPair, PublicKey}; use massa_wallet::Wallet; use std::str; @@ -169,7 +170,122 @@ impl Output for &str { impl Output for NodeStatus { fn pretty_print(&self) { - println!("{}", self); + println!("Node's ID: {}", Style::Id.style(self.node_id)); + if self.node_ip.is_some() { + println!("Node's IP: {}", Style::Protocol.style(self.node_ip.unwrap())); + } else { + println!("{}", Style::Unknown.style("No routable IP set")); + } + println!(); + + println!("Version: {}", Style::Id.style(self.version)); + self.config.pretty_print(); + println!(); + + println!("Current time: {}", self.current_time.to_utc_string()); + println!("Current cycle: {}", Style::Protocol.style(self.current_cycle)); + if self.last_slot.is_some() { + println!("Last slot: {}", Style::Protocol.style(self.last_slot.unwrap())); + } + println!("Next slot: {}", Style::Protocol.style(self.next_slot)); + println!(); + + self.consensus_stats.pretty_print(); + + println!("Pool stats:"); + println!("\tOperations count: {}", Style::Protocol.style(self.pool_stats.0)); + println!("\tEndorsements count: {}", Style::Protocol.style(self.pool_stats.1)); + println!(); + + self.network_stats.pretty_print(); + self.execution_stats.pretty_print(); + + if !self.connected_nodes.is_empty() { + println!("Connected nodes:"); + for (node_id, (ip_addr, is_outgoing)) in &self.connected_nodes { + println!( + "Node's ID: {} / IP address: {} / {} connection", + Style::Id.style(node_id), + Style::Protocol.style(ip_addr), + if *is_outgoing { "Out" } else { "In" } + ) + } + } + } +} + +impl Output for ExecutionStats { + fn pretty_print(&self) { + println!("Execution stats:"); + println!( + "\tStart stats timespan time: {}", + Style::Time.style(self.time_window_start.to_utc_string()) + ); + println!( + "\tEnd stats timespan time: {}", + Style::Time.style(self.time_window_end.to_utc_string()) + ); + println!( + "\tFinal executed block count: {}", + Style::Block.style(self.final_block_count) + ); + println!( + "\tFinal executed operation count: {}", + Style::Protocol.style(self.final_executed_operations_count) + ); + println!("\tActive cursor: {}", Style::Protocol.style(self.active_cursor)); + } +} + +impl Output for NetworkStats { + fn pretty_print(&self) { + println!("Network stats:"); + println!("\tIn connections: {}", Style::Protocol.style(self.in_connection_count)); + println!("\tOut connections: {}", Style::Protocol.style(self.out_connection_count)); + println!("\tKnown peers: {}", Style::Protocol.style(self.known_peer_count)); + println!("\tBanned peers: {}", Style::Bad.style(self.banned_peer_count)); + println!("\tActive nodes: {}", Style::Good.style(self.active_node_count)); + } +} + +impl Output for CompactConfig { + fn pretty_print(&self) { + println!("Config:"); + println!( + "\tGenesis time: {}", + Style::Time.style(self.genesis_timestamp.to_utc_string()) + ); + if let Some(end) = self.end_timestamp { + println!("\tEnd time: {}", Style::Time.style(end.to_utc_string())); + } + println!("\tThread count: {}", Style::Protocol.style(self.thread_count)); + println!("\tt0: {}", Style::Time.style(self.t0)); + println!("\tdelta_f0: {}", Style::Protocol.style(self.delta_f0)); + println!("\tOperation validity periods: {}", + Style::Protocol.style(self.operation_validity_periods) + ); + println!("\tPeriods per cycle: {}", Style::Protocol.style(self.periods_per_cycle)); + println!("\tBlock reward: {}", Style::Coins.style(self.block_reward)); + println!("\tPeriods per cycle: {}", Style::Protocol.style(self.periods_per_cycle)); + println!("\tRoll price: {}", Style::Coins.style(self.roll_price)); + println!("\tMax block size (in bytes): {}", Style::Block.style(self.max_block_size)); + } +} + +impl Output for ConsensusStats { + fn pretty_print(&self) { + println!("Consensus stats:"); + println!( + "\tStart stats timespan time: {}", + Style::Time.style(self.start_timespan.to_utc_string()) + ); + println!( + "\tEnd stats timespan time: {}", + Style::Time.style(self.end_timespan.to_utc_string()) + ); + println!("\tFinal block count: {}", Style::Block.style(self.final_block_count)); + println!("\tStale block count: {}", Style::Block.style(self.stale_block_count)); + println!("\tClique count: {}", Style::Protocol.style(self.clique_count)); } } From 35f105bf0a116ca5434de1f40ac486fd86d87aae Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Thu, 9 Mar 2023 09:25:01 +0100 Subject: [PATCH 11/16] Add Style variant for Time display Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 2ba2c3d1d9a..d1791850a2c 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -74,6 +74,8 @@ pub enum Style { Secret, /// To separate some informations on the screen by barely visible characters Separator, + /// When displaying a timestamp or date + Time, } impl Style { @@ -92,6 +94,7 @@ impl Style { Style::Wallet => 193, // #d7ffaf Style::Secret => 64, // #5f8700 Style::Separator => 239, // #4e4e4e + Style::Time => 117, // #87d7ff }) } } From 1175b2d9152c126bf68415a74cd95f2aadb58d13 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Thu, 9 Mar 2023 09:25:15 +0100 Subject: [PATCH 12/16] Improve the palette Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index d1791850a2c..140f5772f61 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -81,17 +81,17 @@ pub enum Style { impl Style { fn style(&self, msg: T) -> console::StyledObject { style(msg.to_string()).color256(match self { - Style::Id => 175, // #d787af + Style::Id => 218, // #ffafd7 Style::Pending => 172, // #d78700 Style::Finished => 81, // #5fd7ff Style::Good => 112, // #87d700 Style::Bad => 160, // #d70000 Style::Unknown => 248, // #a8a8a8 - Style::Coins => 99, // #875fff - Style::Protocol => 184, // #d7d700 + Style::Coins => 141, // #af87ff + Style::Protocol => 151, // #afd7af Style::Block => 158, // #afffd7 Style::Signature => 220, // #ffd700 - Style::Wallet => 193, // #d7ffaf + Style::Wallet => 213, // #ff87ff Style::Secret => 64, // #5f8700 Style::Separator => 239, // #4e4e4e Style::Time => 117, // #87d7ff From 438a52f3865480ffa22ace8ff3193abb87b7aae2 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 8 Mar 2023 16:12:00 +0100 Subject: [PATCH 13/16] Add colors in CLI for wallet_info Signed-off-by: Litchi Pi --- massa-client/src/cmds.rs | 4 ++-- massa-client/src/display.rs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/massa-client/src/cmds.rs b/massa-client/src/cmds.rs index 076ec7e149c..3b3a75cf160 100644 --- a/massa-client/src/cmds.rs +++ b/massa-client/src/cmds.rs @@ -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 @@ -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); +pub struct ExtendedWallet(pub (crate) PreHashMap); impl ExtendedWallet { /// Reorganize everything into an extended wallet diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 140f5772f61..98902fdda7b 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -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("=====")); + } } } From 4095cccec1274e80ca407febe39be8aadf18ee94 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Thu, 9 Mar 2023 09:40:25 +0100 Subject: [PATCH 14/16] Add colors in CLI for get_addresses Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 56 +++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 140f5772f61..d14a30ae3e2 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -194,8 +194,60 @@ impl Output for PreHashSet
{ impl Output for Vec { fn pretty_print(&self) { - for address_info in self { - println!("{}", address_info); + for info in self { + println!("{}", Style::Separator.style("========")); + println!("Address {} (thread {}):", + Style::Wallet.style(info.address), + Style::Protocol.style(info.thread), + ); + println!( + "\tBalance: {}={}, {}={}", + Style::Finished.style("final"), + Style::Coins.style(info.final_balance), + Style::Pending.style("candidate"), + Style::Coins.style(info.candidate_balance), + ); + println!( + "\tRolls: {}={}, {}={}", + Style::Finished.style("final"), + Style::Protocol.style(info.final_roll_count), + Style::Pending.style("candidate"), + Style::Protocol.style(info.candidate_roll_count), + ); + + print!("\tLocked coins:"); + if info.deferred_credits.is_empty() { + println!(" {}", Style::Coins.style("0")); + } else { + println!(); + for slot_amount in &info.deferred_credits { + println!( + "\t\t{} locked coins will be unlocked at slot {}", + Style::Coins.style(slot_amount.amount), + Style::Protocol.style(slot_amount.slot), + ); + } + } + if !info.cycle_infos.is_empty() { + println!("\tCycle infos:"); + } + for cycle_info in &info.cycle_infos { + println!( + "\t\tCycle {} ({}): produced {} and missed {} blocks{}", + Style::Protocol.style(cycle_info.cycle), + if cycle_info.is_final { + Style::Finished.style("final") + } else { + Style::Pending.style("candidate") + }, + Style::Good.style(cycle_info.ok_count), + Style::Bad.style(cycle_info.nok_count), + match cycle_info.active_rolls { + Some(rolls) => format!(" with {} active rolls", Style::Good.style(rolls)), + None => "".into(), + }, + ); + } } } } From 454452429cb72a0fb257c4bf56a3de0a7a185191 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 22 Mar 2023 09:38:52 +0100 Subject: [PATCH 15/16] fixup formatting Signed-off-by: Litchi Pi --- massa-client/src/cmds.rs | 4 +- massa-client/src/display.rs | 161 +++++++++++++++++++++++++++--------- massa-client/src/main.rs | 2 +- massa-client/src/repl.rs | 8 +- 4 files changed, 127 insertions(+), 48 deletions(-) diff --git a/massa-client/src/cmds.rs b/massa-client/src/cmds.rs index 3b3a75cf160..4cb687322d0 100644 --- a/massa-client/src/cmds.rs +++ b/massa-client/src/cmds.rs @@ -338,7 +338,7 @@ pub enum ListOperation { /// Used to have a shinny json output /// TODO re-factor me #[derive(Debug, Serialize)] -pub (crate) struct ExtendedWalletEntry { +pub(crate) struct ExtendedWalletEntry { /// the keypair pub keypair: KeyPair, /// address and balance information @@ -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(pub (crate) PreHashMap); +pub struct ExtendedWallet(pub(crate) PreHashMap); impl ExtendedWallet { /// Reorganize everything into an extended wallet diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index bbdc3623acf..45811e82859 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -11,12 +11,12 @@ use massa_api_exports::{ use massa_models::composite::PubkeySig; use massa_models::output_event::SCOutputEvent; use massa_models::prehash::PreHashSet; -use massa_models::{address::Address, operation::OperationId, config::CompactConfig}; use massa_models::stats::{ConsensusStats, ExecutionStats, NetworkStats}; +use massa_models::{address::Address, config::CompactConfig, operation::OperationId}; use massa_signature::{KeyPair, PublicKey}; use massa_wallet::Wallet; -use std::str; use std::net::IpAddr; +use std::str; #[macro_export] macro_rules! massa_fancy_ascii_art_logo { @@ -128,9 +128,13 @@ impl Output for ExtendedWallet { 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!( + "Public key: {}", + Style::Wallet.style(entry.keypair.get_public_key()) + ); } - println!("Address: {} (thread {}):", + println!( + "Address: {} (thread {}):", Style::Wallet.style(entry.address_info.address), Style::Protocol.style(entry.address_info.thread), ); @@ -205,7 +209,10 @@ impl Output for NodeStatus { fn pretty_print(&self) { println!("Node's ID: {}", Style::Id.style(self.node_id)); if self.node_ip.is_some() { - println!("Node's IP: {}", Style::Protocol.style(self.node_ip.unwrap())); + println!( + "Node's IP: {}", + Style::Protocol.style(self.node_ip.unwrap()) + ); } else { println!("{}", Style::Unknown.style("No routable IP set")); } @@ -216,9 +223,15 @@ impl Output for NodeStatus { println!(); println!("Current time: {}", self.current_time.to_utc_string()); - println!("Current cycle: {}", Style::Protocol.style(self.current_cycle)); + println!( + "Current cycle: {}", + Style::Protocol.style(self.current_cycle) + ); if self.last_slot.is_some() { - println!("Last slot: {}", Style::Protocol.style(self.last_slot.unwrap())); + println!( + "Last slot: {}", + Style::Protocol.style(self.last_slot.unwrap()) + ); } println!("Next slot: {}", Style::Protocol.style(self.next_slot)); println!(); @@ -226,8 +239,14 @@ impl Output for NodeStatus { self.consensus_stats.pretty_print(); println!("Pool stats:"); - println!("\tOperations count: {}", Style::Protocol.style(self.pool_stats.0)); - println!("\tEndorsements count: {}", Style::Protocol.style(self.pool_stats.1)); + println!( + "\tOperations count: {}", + Style::Protocol.style(self.pool_stats.0) + ); + println!( + "\tEndorsements count: {}", + Style::Protocol.style(self.pool_stats.1) + ); println!(); self.network_stats.pretty_print(); @@ -266,18 +285,36 @@ impl Output for ExecutionStats { "\tFinal executed operation count: {}", Style::Protocol.style(self.final_executed_operations_count) ); - println!("\tActive cursor: {}", Style::Protocol.style(self.active_cursor)); + println!( + "\tActive cursor: {}", + Style::Protocol.style(self.active_cursor) + ); } } impl Output for NetworkStats { fn pretty_print(&self) { println!("Network stats:"); - println!("\tIn connections: {}", Style::Protocol.style(self.in_connection_count)); - println!("\tOut connections: {}", Style::Protocol.style(self.out_connection_count)); - println!("\tKnown peers: {}", Style::Protocol.style(self.known_peer_count)); - println!("\tBanned peers: {}", Style::Bad.style(self.banned_peer_count)); - println!("\tActive nodes: {}", Style::Good.style(self.active_node_count)); + println!( + "\tIn connections: {}", + Style::Protocol.style(self.in_connection_count) + ); + println!( + "\tOut connections: {}", + Style::Protocol.style(self.out_connection_count) + ); + println!( + "\tKnown peers: {}", + Style::Protocol.style(self.known_peer_count) + ); + println!( + "\tBanned peers: {}", + Style::Bad.style(self.banned_peer_count) + ); + println!( + "\tActive nodes: {}", + Style::Good.style(self.active_node_count) + ); } } @@ -291,17 +328,30 @@ impl Output for CompactConfig { if let Some(end) = self.end_timestamp { println!("\tEnd time: {}", Style::Time.style(end.to_utc_string())); } - println!("\tThread count: {}", Style::Protocol.style(self.thread_count)); + println!( + "\tThread count: {}", + Style::Protocol.style(self.thread_count) + ); println!("\tt0: {}", Style::Time.style(self.t0)); println!("\tdelta_f0: {}", Style::Protocol.style(self.delta_f0)); - println!("\tOperation validity periods: {}", + println!( + "\tOperation validity periods: {}", Style::Protocol.style(self.operation_validity_periods) ); - println!("\tPeriods per cycle: {}", Style::Protocol.style(self.periods_per_cycle)); + println!( + "\tPeriods per cycle: {}", + Style::Protocol.style(self.periods_per_cycle) + ); println!("\tBlock reward: {}", Style::Coins.style(self.block_reward)); - println!("\tPeriods per cycle: {}", Style::Protocol.style(self.periods_per_cycle)); + println!( + "\tPeriods per cycle: {}", + Style::Protocol.style(self.periods_per_cycle) + ); println!("\tRoll price: {}", Style::Coins.style(self.roll_price)); - println!("\tMax block size (in bytes): {}", Style::Block.style(self.max_block_size)); + println!( + "\tMax block size (in bytes): {}", + Style::Block.style(self.max_block_size) + ); } } @@ -316,9 +366,18 @@ impl Output for ConsensusStats { "\tEnd stats timespan time: {}", Style::Time.style(self.end_timespan.to_utc_string()) ); - println!("\tFinal block count: {}", Style::Block.style(self.final_block_count)); - println!("\tStale block count: {}", Style::Block.style(self.stale_block_count)); - println!("\tClique count: {}", Style::Protocol.style(self.clique_count)); + println!( + "\tFinal block count: {}", + Style::Block.style(self.final_block_count) + ); + println!( + "\tStale block count: {}", + Style::Block.style(self.stale_block_count) + ); + println!( + "\tClique count: {}", + Style::Protocol.style(self.clique_count) + ); } } @@ -342,7 +401,8 @@ impl Output for Vec { fn pretty_print(&self) { for info in self { println!("{}", Style::Separator.style("========")); - println!("Address {} (thread {}):", + println!( + "Address {} (thread {}):", Style::Wallet.style(info.address), Style::Protocol.style(info.thread), ); @@ -431,19 +491,25 @@ impl Output for Vec { print!(", {}", Style::Pending.style("in pool")); } if let Some(f) = info.is_operation_final { - print!(", operation is {}", if f { - Style::Finished.style("final") - } else { - Style::Pending.style("not final") - }); + print!( + ", operation is {}", + if f { + Style::Finished.style("final") + } else { + Style::Pending.style("not final") + } + ); } else { print!(", finality {}", Style::Unknown.style("unknown")); } - println!(", {}", match info.op_exec_status { - Some(true) => Style::Good.style("success"), - Some(false) => Style::Bad.style("failed"), - None => Style::Unknown.style("unknown status"), - }); + println!( + ", {}", + match info.op_exec_status { + Some(true) => Style::Good.style("success"), + Some(false) => Style::Bad.style("failed"), + None => Style::Unknown.style("unknown status"), + } + ); if info.in_blocks.is_empty() { println!("{}", Style::Block.style("Not in any blocks")); } else { @@ -452,14 +518,27 @@ impl Output for Vec { println!("\t- {}", Style::Block.style(bid)); } } - println!("Signature: {}", Style::Signature.style(info.operation.signature)); - println!("Creator pubkey: {}", - Style::Wallet.style(info.operation.content_creator_pub_key)); - println!("Creator address: {}", - Style::Wallet.style(info.operation.content_creator_address)); + println!( + "Signature: {}", + Style::Signature.style(info.operation.signature) + ); + println!( + "Creator pubkey: {}", + Style::Wallet.style(info.operation.content_creator_pub_key) + ); + println!( + "Creator address: {}", + Style::Wallet.style(info.operation.content_creator_address) + ); println!("Fee: {}", Style::Coins.style(info.operation.content.fee)); - println!("Expire period: {}", Style::Pending.style(info.operation.content.expire_period)); - println!("Operation type: {}", Style::Id.style(&info.operation.content.op)); + println!( + "Expire period: {}", + Style::Pending.style(info.operation.content.expire_period) + ); + println!( + "Operation type: {}", + Style::Id.style(&info.operation.content.op) + ); } } } diff --git a/massa-client/src/main.rs b/massa-client/src/main.rs index 4224da42cf4..d5949e9c604 100644 --- a/massa-client/src/main.rs +++ b/massa-client/src/main.rs @@ -18,9 +18,9 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use structopt::StructOpt; mod cmds; +mod display; mod repl; mod settings; -mod display; #[cfg(test)] pub mod tests; diff --git a/massa-client/src/repl.rs b/massa-client/src/repl.rs index 1dd0a236567..816e36074b7 100644 --- a/massa-client/src/repl.rs +++ b/massa-client/src/repl.rs @@ -2,17 +2,17 @@ use crate::ask_password; use crate::cmds::Command; -use crate::settings::SETTINGS; use crate::massa_fancy_ascii_art_logo; -use massa_sdk::Client; -use massa_wallet::Wallet; +use crate::settings::SETTINGS; use anyhow::Result; use console::style; +use massa_sdk::Client; +use massa_wallet::Wallet; +use rustyline::completion::{Completer, FilenameCompleter, Pair}; use rustyline::error::ReadlineError; use rustyline::validate::MatchingBracketValidator; use rustyline::{CompletionType, Config, Editor}; use rustyline_derive::{Completer, Helper, Highlighter, Hinter, Validator}; -use rustyline::completion::{Completer, FilenameCompleter, Pair}; use std::env; use std::path::Path; use strum::IntoEnumIterator; From afdbff9ad261974777f3d1ec7759eb65d38f7293 Mon Sep 17 00:00:00 2001 From: Litchi Pi Date: Wed, 22 Mar 2023 14:59:32 +0100 Subject: [PATCH 16/16] add documentation to the massa_fancy_ascii_art_logo macro Signed-off-by: Litchi Pi --- massa-client/src/display.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 45811e82859..230936b9457 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -19,6 +19,7 @@ use std::net::IpAddr; use std::str; #[macro_export] +/// Display the MASSA logo on the CLI with fancy colors macro_rules! massa_fancy_ascii_art_logo { () => { println!(