v1.1
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
use std::net::Ipv4Addr;
|
||||
use console::style;
|
||||
|
||||
use switch::Route;
|
||||
|
||||
use crate::command::entity::{DeviceItem, RouteItem, Status};
|
||||
|
||||
pub mod table;
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
const NODE: &str = "+";
|
||||
const EDGE: &str = "-";
|
||||
const HIGH: &str = "|";
|
||||
const SPACE: &str = " ";
|
||||
const EMPTY: &str = "";
|
||||
use console::style;
|
||||
|
||||
pub fn println_table(table: Vec<Vec<String>>) {
|
||||
if table.is_empty() {
|
||||
@@ -11,16 +7,23 @@ pub fn println_table(table: Vec<Vec<String>>) {
|
||||
let mut width_list = vec![0; table[0].len()];
|
||||
for in_list in table.iter() {
|
||||
for (index, item) in in_list.iter().enumerate() {
|
||||
let width = console::measure_text_width(item)+6;
|
||||
let width = console::measure_text_width(item) + 6;
|
||||
if width_list[index] < width {
|
||||
width_list[index] = width;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut head = true;
|
||||
for in_list in table {
|
||||
for (index, item) in in_list.iter().enumerate() {
|
||||
print!("{item:width$}", item = item, width = width_list[index]);
|
||||
if head {
|
||||
print!("{item:width$}", item = item, width = width_list[index]);
|
||||
} else {
|
||||
let str = format!("{item:width$}", item = item, width = width_list[index]);
|
||||
print!("{}", style(str).green());
|
||||
}
|
||||
}
|
||||
head = false;
|
||||
println!()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user