list.rs
1 use radicle_term::{Element, Table}; 2 3 use crate::git; 4 use crate::terminal as term; 5 6 pub fn run(repo: &git::Repository) -> anyhow::Result<()> { 7 let mut table = Table::default(); 8 let remotes = git::rad_remotes(repo)?; 9 for r in remotes { 10 for (dir, url) in [("fetch", Some(r.url)), ("push", r.pushurl)] { 11 let Some(url) = url else { 12 continue; 13 }; 14 15 let description = url.namespace.map_or( 16 term::format::dim("(canonical upstream)".to_string()).italic(), 17 |namespace| term::format::tertiary(namespace.to_string()), 18 ); 19 table.push([ 20 term::format::bold(r.name.clone()), 21 description, 22 term::format::parens(term::format::secondary(dir.to_owned())), 23 ]); 24 } 25 } 26 table.print(); 27 28 Ok(()) 29 }