Print the header as a footer when there's a large number of validators to show
This commit is contained in:
parent
818c3198c1
commit
1824b5a2ce
|
@ -378,12 +378,9 @@ impl fmt::Display for CliValidators {
|
|||
}
|
||||
|
||||
let padding = ((self.validators.len() + 1) as f64).log10().floor() as usize + 1;
|
||||
write!(f, "{:padding$}", " ", padding = padding)?;
|
||||
writeln!(
|
||||
f,
|
||||
"{}",
|
||||
style(format!(
|
||||
" {:<44} {:<38} {} {} {} {:>11} {:^7} {}",
|
||||
let header = style(format!(
|
||||
"{:padding$} {:<44} {:<38} {} {} {} {:>11} {:^7} {}",
|
||||
" ",
|
||||
"Identity",
|
||||
"Vote Account",
|
||||
"Commission",
|
||||
|
@ -392,9 +389,10 @@ impl fmt::Display for CliValidators {
|
|||
"Epoch Credits",
|
||||
"Version",
|
||||
"Active Stake",
|
||||
padding = padding
|
||||
))
|
||||
.bold()
|
||||
)?;
|
||||
.bold();
|
||||
writeln!(f, "{}", header)?;
|
||||
|
||||
let mut sorted_validators = self.validators.clone();
|
||||
match self.validators_sort_order {
|
||||
|
@ -438,6 +436,11 @@ impl fmt::Display for CliValidators {
|
|||
)?;
|
||||
}
|
||||
|
||||
// The actual header has long scrolled away. Print the header once more as a footer
|
||||
if self.validators.len() > 100 {
|
||||
writeln!(f, "{}", header)?;
|
||||
}
|
||||
|
||||
writeln!(f)?;
|
||||
writeln_name_value(
|
||||
f,
|
||||
|
|
Loading…
Reference in New Issue