cli/remote: Replace manual building table from iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
4bd45cdabd
commit
9c2f97abe1
|
|
@ -81,10 +81,9 @@ pub fn untracked<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_tracked<'a>(tracked: impl Iterator<Item = &'a Tracked>) {
|
pub fn print_tracked<'a>(tracked: impl Iterator<Item = &'a Tracked>) {
|
||||||
let mut table = Table::default();
|
Table::from_iter(tracked.into_iter().flat_map(|Tracked { direction, name }| {
|
||||||
for Tracked { direction, name } in tracked {
|
|
||||||
let Some(direction) = direction else {
|
let Some(direction) = direction else {
|
||||||
continue;
|
return None;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (dir, url) = match direction {
|
let (dir, url) = match direction {
|
||||||
|
|
@ -95,25 +94,24 @@ pub fn print_tracked<'a>(tracked: impl Iterator<Item = &'a Tracked>) {
|
||||||
term::format::dim("(canonical upstream)".to_string()).italic(),
|
term::format::dim("(canonical upstream)".to_string()).italic(),
|
||||||
|namespace| term::format::tertiary(namespace.to_string()),
|
|namespace| term::format::tertiary(namespace.to_string()),
|
||||||
);
|
);
|
||||||
table.push([
|
Some([
|
||||||
term::format::bold(name.clone()),
|
term::format::bold(name.clone()),
|
||||||
description,
|
description,
|
||||||
term::format::parens(term::format::secondary(dir.to_owned())),
|
term::format::parens(term::format::secondary(dir.to_owned())),
|
||||||
]);
|
])
|
||||||
}
|
}))
|
||||||
table.print();
|
.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_untracked<'a>(untracked: impl Iterator<Item = &'a Untracked>) {
|
pub fn print_untracked<'a>(untracked: impl Iterator<Item = &'a Untracked>) {
|
||||||
let mut t = Table::default();
|
Table::from_iter(untracked.into_iter().map(|Untracked { remote, alias }| {
|
||||||
for Untracked { remote, alias } in untracked {
|
[
|
||||||
t.push([
|
|
||||||
match alias {
|
match alias {
|
||||||
None => term::format::secondary("n/a".to_string()),
|
None => term::format::secondary("n/a".to_string()),
|
||||||
Some(alias) => term::format::secondary(alias.to_string()),
|
Some(alias) => term::format::secondary(alias.to_string()),
|
||||||
},
|
},
|
||||||
term::format::highlight(Did::from(remote).to_string()),
|
term::format::highlight(Did::from(remote).to_string()),
|
||||||
])
|
]
|
||||||
}
|
}))
|
||||||
t.print();
|
.print();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue