mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
replace cyan and yellow which not easy to read on white background (#1903)
* replace cyan and yellow which not easy to read on white background * wallet output color scheme configuration for terminal dark/white background * use true for dark_background_color_scheme to make the default behavior same as before
This commit is contained in:
parent
cc63fe4d32
commit
f645937a2b
4 changed files with 140 additions and 38 deletions
|
@ -344,6 +344,12 @@ fn comments() -> HashMap<String, String> {
|
||||||
"data_file_dir".to_string(),
|
"data_file_dir".to_string(),
|
||||||
"
|
"
|
||||||
#where to find wallet files (seed, data, etc)
|
#where to find wallet files (seed, data, etc)
|
||||||
|
".to_string(),
|
||||||
|
);
|
||||||
|
retval.insert(
|
||||||
|
"dark_background_color_scheme".to_string(),
|
||||||
|
"
|
||||||
|
#Whether to use the black background color scheme for command line
|
||||||
".to_string(),
|
".to_string(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -434,13 +434,24 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
e, wallet_config
|
e, wallet_config
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
display::info(account, &wallet_info, validated);
|
display::info(
|
||||||
|
account,
|
||||||
|
&wallet_info,
|
||||||
|
validated,
|
||||||
|
wallet_config.dark_background_color_scheme.unwrap(),
|
||||||
|
);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
("outputs", Some(_)) => {
|
("outputs", Some(_)) => {
|
||||||
let (height, _) = api.node_height()?;
|
let (height, _) = api.node_height()?;
|
||||||
let (validated, outputs) = api.retrieve_outputs(show_spent, true, None)?;
|
let (validated, outputs) = api.retrieve_outputs(show_spent, true, None)?;
|
||||||
display::outputs(account, height, validated, outputs).map_err(|e| {
|
display::outputs(
|
||||||
|
account,
|
||||||
|
height,
|
||||||
|
validated,
|
||||||
|
outputs,
|
||||||
|
wallet_config.dark_background_color_scheme.unwrap(),
|
||||||
|
).map_err(|e| {
|
||||||
ErrorKind::GenericError(format!(
|
ErrorKind::GenericError(format!(
|
||||||
"Error getting wallet outputs: {:?} Config: {:?}",
|
"Error getting wallet outputs: {:?} Config: {:?}",
|
||||||
e, wallet_config
|
e, wallet_config
|
||||||
|
@ -462,7 +473,14 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
let (height, _) = api.node_height()?;
|
let (height, _) = api.node_height()?;
|
||||||
let (validated, txs) = api.retrieve_txs(true, tx_id)?;
|
let (validated, txs) = api.retrieve_txs(true, tx_id)?;
|
||||||
let include_status = !tx_id.is_some();
|
let include_status = !tx_id.is_some();
|
||||||
display::txs(account, height, validated, txs, include_status).map_err(|e| {
|
display::txs(
|
||||||
|
account,
|
||||||
|
height,
|
||||||
|
validated,
|
||||||
|
txs,
|
||||||
|
include_status,
|
||||||
|
wallet_config.dark_background_color_scheme.unwrap(),
|
||||||
|
).map_err(|e| {
|
||||||
ErrorKind::GenericError(format!(
|
ErrorKind::GenericError(format!(
|
||||||
"Error getting wallet outputs: {} Config: {:?}",
|
"Error getting wallet outputs: {} Config: {:?}",
|
||||||
e, wallet_config
|
e, wallet_config
|
||||||
|
@ -472,7 +490,13 @@ pub fn wallet_command(wallet_args: &ArgMatches, config: GlobalWalletConfig) {
|
||||||
// inputs/outputs
|
// inputs/outputs
|
||||||
if tx_id.is_some() {
|
if tx_id.is_some() {
|
||||||
let (_, outputs) = api.retrieve_outputs(true, false, tx_id)?;
|
let (_, outputs) = api.retrieve_outputs(true, false, tx_id)?;
|
||||||
display::outputs(account, height, validated, outputs).map_err(|e| {
|
display::outputs(
|
||||||
|
account,
|
||||||
|
height,
|
||||||
|
validated,
|
||||||
|
outputs,
|
||||||
|
wallet_config.dark_background_color_scheme.unwrap(),
|
||||||
|
).map_err(|e| {
|
||||||
ErrorKind::GenericError(format!(
|
ErrorKind::GenericError(format!(
|
||||||
"Error getting wallet outputs: {} Config: {:?}",
|
"Error getting wallet outputs: {} Config: {:?}",
|
||||||
e, wallet_config
|
e, wallet_config
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub fn outputs(
|
||||||
cur_height: u64,
|
cur_height: u64,
|
||||||
validated: bool,
|
validated: bool,
|
||||||
outputs: Vec<(OutputData, pedersen::Commitment)>,
|
outputs: Vec<(OutputData, pedersen::Commitment)>,
|
||||||
|
dark_background_color_scheme: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let title = format!(
|
let title = format!(
|
||||||
"Wallet Outputs - Account '{}' - Block Height: {}",
|
"Wallet Outputs - Account '{}' - Block Height: {}",
|
||||||
|
@ -69,6 +70,8 @@ pub fn outputs(
|
||||||
None => "".to_owned(),
|
None => "".to_owned(),
|
||||||
Some(t) => t.to_string(),
|
Some(t) => t.to_string(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if dark_background_color_scheme {
|
||||||
table.add_row(row![
|
table.add_row(row![
|
||||||
bFC->commit,
|
bFC->commit,
|
||||||
bFB->height,
|
bFB->height,
|
||||||
|
@ -79,6 +82,18 @@ pub fn outputs(
|
||||||
bFG->value,
|
bFG->value,
|
||||||
bFC->tx,
|
bFC->tx,
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
table.add_row(row![
|
||||||
|
bFD->commit,
|
||||||
|
bFB->height,
|
||||||
|
bFB->lock_height,
|
||||||
|
bFR->status,
|
||||||
|
bFD->is_coinbase,
|
||||||
|
bFB->num_confirmations,
|
||||||
|
bFG->value,
|
||||||
|
bFD->tx,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.set_format(*prettytable::format::consts::FORMAT_NO_COLSEP);
|
table.set_format(*prettytable::format::consts::FORMAT_NO_COLSEP);
|
||||||
|
@ -102,6 +117,7 @@ pub fn txs(
|
||||||
validated: bool,
|
validated: bool,
|
||||||
txs: Vec<TxLogEntry>,
|
txs: Vec<TxLogEntry>,
|
||||||
include_status: bool,
|
include_status: bool,
|
||||||
|
dark_background_color_scheme: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let title = format!(
|
let title = format!(
|
||||||
"Transaction Log - Account '{}' - Block Height: {}",
|
"Transaction Log - Account '{}' - Block Height: {}",
|
||||||
|
@ -164,6 +180,7 @@ pub fn txs(
|
||||||
Some(_) => format!("Exists"),
|
Some(_) => format!("Exists"),
|
||||||
None => "None".to_owned(),
|
None => "None".to_owned(),
|
||||||
};
|
};
|
||||||
|
if dark_background_color_scheme {
|
||||||
table.add_row(row![
|
table.add_row(row![
|
||||||
bFC->id,
|
bFC->id,
|
||||||
bFC->entry_type,
|
bFC->entry_type,
|
||||||
|
@ -179,6 +196,41 @@ pub fn txs(
|
||||||
bFY->net_diff,
|
bFY->net_diff,
|
||||||
bFb->tx_data,
|
bFb->tx_data,
|
||||||
]);
|
]);
|
||||||
|
} else {
|
||||||
|
if t.confirmed {
|
||||||
|
table.add_row(row![
|
||||||
|
bFD->id,
|
||||||
|
bFb->entry_type,
|
||||||
|
bFD->slate_id,
|
||||||
|
bFB->creation_ts,
|
||||||
|
bFg->confirmed,
|
||||||
|
bFB->confirmation_ts,
|
||||||
|
bFD->num_inputs,
|
||||||
|
bFD->num_outputs,
|
||||||
|
bFG->amount_credited_str,
|
||||||
|
bFD->amount_debited_str,
|
||||||
|
bFD->fee,
|
||||||
|
bFG->net_diff,
|
||||||
|
bFB->tx_data,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
table.add_row(row![
|
||||||
|
bFD->id,
|
||||||
|
bFb->entry_type,
|
||||||
|
bFD->slate_id,
|
||||||
|
bFB->creation_ts,
|
||||||
|
bFR->confirmed,
|
||||||
|
bFB->confirmation_ts,
|
||||||
|
bFD->num_inputs,
|
||||||
|
bFD->num_outputs,
|
||||||
|
bFG->amount_credited_str,
|
||||||
|
bFD->amount_debited_str,
|
||||||
|
bFD->fee,
|
||||||
|
bFG->net_diff,
|
||||||
|
bFB->tx_data,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
table.set_format(*prettytable::format::consts::FORMAT_NO_COLSEP);
|
table.set_format(*prettytable::format::consts::FORMAT_NO_COLSEP);
|
||||||
|
@ -195,19 +247,35 @@ pub fn txs(
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
/// Display summary info in a pretty way
|
/// Display summary info in a pretty way
|
||||||
pub fn info(account: &str, wallet_info: &WalletInfo, validated: bool) {
|
pub fn info(
|
||||||
|
account: &str,
|
||||||
|
wallet_info: &WalletInfo,
|
||||||
|
validated: bool,
|
||||||
|
dark_background_color_scheme: bool,
|
||||||
|
) {
|
||||||
println!(
|
println!(
|
||||||
"\n____ Wallet Summary Info - Account '{}' as of height {} ____\n",
|
"\n____ Wallet Summary Info - Account '{}' as of height {} ____\n",
|
||||||
account, wallet_info.last_confirmed_height
|
account, wallet_info.last_confirmed_height
|
||||||
);
|
);
|
||||||
let mut table = table!(
|
let mut table = if dark_background_color_scheme {
|
||||||
|
table!(
|
||||||
[bFG->"Total", FG->amount_to_hr_string(wallet_info.total, false)],
|
[bFG->"Total", FG->amount_to_hr_string(wallet_info.total, false)],
|
||||||
[bFY->"Awaiting Confirmation", FY->amount_to_hr_string(wallet_info.amount_awaiting_confirmation, false)],
|
[bFY->"Awaiting Confirmation", FY->amount_to_hr_string(wallet_info.amount_awaiting_confirmation, false)],
|
||||||
[bFY->"Immature Coinbase", FY->amount_to_hr_string(wallet_info.amount_immature, false)],
|
[bFY->"Immature Coinbase", FY->amount_to_hr_string(wallet_info.amount_immature, false)],
|
||||||
[bFG->"Currently Spendable", FG->amount_to_hr_string(wallet_info.amount_currently_spendable, false)],
|
[bFG->"Currently Spendable", FG->amount_to_hr_string(wallet_info.amount_currently_spendable, false)],
|
||||||
[Fw->"---------", Fw->"---------"],
|
[Fw->"--------------------------------", Fw->"-------------"],
|
||||||
[Fr->"(Locked by previous transaction)", Fr->amount_to_hr_string(wallet_info.amount_locked, false)]
|
[Fr->"(Locked by previous transaction)", Fr->amount_to_hr_string(wallet_info.amount_locked, false)]
|
||||||
);
|
)
|
||||||
|
} else {
|
||||||
|
table!(
|
||||||
|
[bFG->"Total", FG->amount_to_hr_string(wallet_info.total, false)],
|
||||||
|
[bFB->"Awaiting Confirmation", FB->amount_to_hr_string(wallet_info.amount_awaiting_confirmation, false)],
|
||||||
|
[bFB->"Immature Coinbase", FB->amount_to_hr_string(wallet_info.amount_immature, false)],
|
||||||
|
[bFG->"Currently Spendable", FG->amount_to_hr_string(wallet_info.amount_currently_spendable, false)],
|
||||||
|
[Fw->"--------------------------------", Fw->"-------------"],
|
||||||
|
[Fr->"(Locked by previous transaction)", Fr->amount_to_hr_string(wallet_info.amount_locked, false)]
|
||||||
|
)
|
||||||
|
};
|
||||||
table.set_format(*prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR);
|
table.set_format(*prettytable::format::consts::FORMAT_NO_BORDER_LINE_SEPARATOR);
|
||||||
table.printstd();
|
table.printstd();
|
||||||
println!();
|
println!();
|
||||||
|
|
|
@ -51,6 +51,9 @@ pub struct WalletConfig {
|
||||||
pub tls_certificate_file: Option<String>,
|
pub tls_certificate_file: Option<String>,
|
||||||
/// TLS ceritificate private key file
|
/// TLS ceritificate private key file
|
||||||
pub tls_certificate_key: Option<String>,
|
pub tls_certificate_key: Option<String>,
|
||||||
|
/// Whether to use the black background color scheme for command line
|
||||||
|
/// if enabled, wallet command output color will be suitable for black background terminal
|
||||||
|
pub dark_background_color_scheme: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for WalletConfig {
|
impl Default for WalletConfig {
|
||||||
|
@ -65,6 +68,7 @@ impl Default for WalletConfig {
|
||||||
data_file_dir: ".".to_string(),
|
data_file_dir: ".".to_string(),
|
||||||
tls_certificate_file: None,
|
tls_certificate_file: None,
|
||||||
tls_certificate_key: None,
|
tls_certificate_key: None,
|
||||||
|
dark_background_color_scheme: Some(true),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue