term: Add border support for tables

This commit is contained in:
Alexis Sellier
2023-03-27 17:46:32 +02:00
parent af99d6f47a
commit 6fb6cff708
9 changed files with 267 additions and 73 deletions
+3 -5
View File
@@ -4,15 +4,13 @@ use crate::terminal as term;
use crate::terminal::Element;
pub fn run<S: node::routing::Store>(routing: &S) -> anyhow::Result<()> {
let mut t = term::Table::new(term::table::TableOptions::default());
let mut t = term::Table::new(term::table::TableOptions::bordered());
t.push([
term::format::default(String::from("RID")),
term::format::default(String::from("NID")),
]);
t.push([
term::format::default(String::from("---")),
term::format::default(String::from("---")),
]);
t.divider();
for (id, node) in routing.entries()? {
t.push([
term::format::highlight(id.to_string()),
+6 -12
View File
@@ -15,17 +15,14 @@ pub fn run(store: &tracking::store::Config, mode: TrackingMode) -> anyhow::Resul
}
fn print_repos(store: &tracking::store::Config) -> anyhow::Result<()> {
let mut t = term::Table::new(term::table::TableOptions::default());
let mut t = term::Table::new(term::table::TableOptions::bordered());
t.push([
term::format::default(String::from("RID")),
term::format::default(String::from("Scope")),
term::format::default(String::from("Policy")),
]);
t.push([
term::format::default(String::from("---")),
term::format::default(String::from("-----")),
term::format::default(String::from("------")),
]);
t.divider();
for tracking::Repo { id, scope, policy } in store.repo_policies()? {
let id = id.to_string();
let scope = scope.to_string();
@@ -43,17 +40,14 @@ fn print_repos(store: &tracking::store::Config) -> anyhow::Result<()> {
}
fn print_nodes(store: &tracking::store::Config) -> anyhow::Result<()> {
let mut t = term::Table::new(term::table::TableOptions::default());
let mut t = term::Table::new(term::table::TableOptions::bordered());
t.push([
term::format::default(String::from("DID")),
term::format::default(String::from("Alias")),
term::format::default(String::from("Policy")),
]);
t.push([
term::format::default(String::from("---")),
term::format::default(String::from("-----")),
term::format::default(String::from("------")),
]);
t.divider();
for tracking::Node { id, alias, policy } in store.node_policies()? {
t.push([
term::format::highlight(Did::from(id).to_string()),