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 to the CLI #3661

Merged
merged 20 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2797239
Add Style enum to get generic styling on the CLI
litchipi Mar 8, 2023
a2265b8
Add comments on the generic styles
litchipi Mar 8, 2023
aa08a5a
Rename 'fee' generic style to 'coins', lighten its color
litchipi Mar 8, 2023
6bb6f1a
Split display-specific function into a separate module
litchipi Mar 8, 2023
22c6c2a
Add separator generic style element
litchipi Mar 8, 2023
5d99498
Rename Style::Address to Style::Wallet, add Style::Protocol
litchipi Mar 8, 2023
0fa3db9
Add comments with colors on each style, change some colors
litchipi Mar 8, 2023
c26eac3
Add colors in CLI for get_operations
litchipi Mar 8, 2023
8f834c3
Merge pull request #3660 from massalabs/cli_colors_get_operations
litchipi Mar 8, 2023
73d5fbc
Fix forgotten rename of Style in get_operations
litchipi Mar 9, 2023
9b2b70d
Add colors in CLI for get_status
litchipi Mar 9, 2023
35f105b
Add Style variant for Time display
litchipi Mar 9, 2023
1175b2d
Improve the palette
litchipi Mar 9, 2023
438a52f
Add colors in CLI for wallet_info
litchipi Mar 8, 2023
4095ccc
Add colors in CLI for get_addresses
litchipi Mar 9, 2023
2d7e176
Merge pull request #3665 from massalabs/cli_colors_get_status
litchipi Mar 13, 2023
cc208a6
Merge pull request #3667 from massalabs/cli_colors_get_addresses
litchipi Mar 13, 2023
8e4c14e
Merge pull request #3662 from massalabs/cli_colors_wallet_info
litchipi Mar 13, 2023
4544524
fixup formatting
litchipi Mar 22, 2023
afdbff9
add documentation to the massa_fancy_ascii_art_logo macro
litchipi Mar 22, 2023
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
33 changes: 10 additions & 23 deletions massa-client/src/cmds.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2022 MASSA LABS <[email protected]>

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::{
Expand Down Expand Up @@ -334,30 +335,10 @@ 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)]
struct ExtendedWalletEntry {
pub(crate) struct ExtendedWalletEntry {
/// the keypair
pub keypair: KeyPair,
/// address and balance information
Expand All @@ -381,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 Expand Up @@ -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()
}
Loading