cli/issue: Replace manual pushing with Table::extend()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
8554e996b8
commit
2f28232676
|
|
@ -782,7 +782,7 @@ where
|
||||||
]);
|
]);
|
||||||
table.divider();
|
table.divider();
|
||||||
|
|
||||||
for (id, issue) in all {
|
table.extend(all.into_iter().map(|(id, issue)| {
|
||||||
let assigned: String = issue
|
let assigned: String = issue
|
||||||
.assignees()
|
.assignees()
|
||||||
.map(|did| {
|
.map(|did| {
|
||||||
|
|
@ -799,34 +799,46 @@ where
|
||||||
let author = issue.author().id;
|
let author = issue.author().id;
|
||||||
let (alias, did) = Author::new(&author, profile, false).labels();
|
let (alias, did) = Author::new(&author, profile, false).labels();
|
||||||
|
|
||||||
table.push([
|
mk_issue_row(id, issue, assigned, labels, alias, did)
|
||||||
match issue.state() {
|
}));
|
||||||
State::Open => term::format::positive("●").into(),
|
|
||||||
State::Closed { .. } => term::format::negative("●").into(),
|
|
||||||
},
|
|
||||||
term::format::tertiary(term::format::cob(&id))
|
|
||||||
.to_owned()
|
|
||||||
.into(),
|
|
||||||
term::format::default(issue.title().to_owned()).into(),
|
|
||||||
alias.into(),
|
|
||||||
did.into(),
|
|
||||||
term::format::secondary(labels.join(", ")).into(),
|
|
||||||
if assigned.is_empty() {
|
|
||||||
term::format::dim(String::default()).into()
|
|
||||||
} else {
|
|
||||||
term::format::primary(assigned.to_string()).dim().into()
|
|
||||||
},
|
|
||||||
term::format::timestamp(issue.timestamp())
|
|
||||||
.dim()
|
|
||||||
.italic()
|
|
||||||
.into(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
table.print();
|
table.print();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mk_issue_row(
|
||||||
|
id: cob::ObjectId,
|
||||||
|
issue: issue::Issue,
|
||||||
|
assigned: String,
|
||||||
|
labels: Vec<String>,
|
||||||
|
alias: radicle_term::Label,
|
||||||
|
did: radicle_term::Label,
|
||||||
|
) -> [radicle_term::Line; 8] {
|
||||||
|
[
|
||||||
|
match issue.state() {
|
||||||
|
State::Open => term::format::positive("●").into(),
|
||||||
|
State::Closed { .. } => term::format::negative("●").into(),
|
||||||
|
},
|
||||||
|
term::format::tertiary(term::format::cob(&id))
|
||||||
|
.to_owned()
|
||||||
|
.into(),
|
||||||
|
term::format::default(issue.title().to_owned()).into(),
|
||||||
|
alias.into(),
|
||||||
|
did.into(),
|
||||||
|
term::format::secondary(labels.join(", ")).into(),
|
||||||
|
if assigned.is_empty() {
|
||||||
|
term::format::dim(String::default()).into()
|
||||||
|
} else {
|
||||||
|
term::format::primary(assigned.to_string()).dim().into()
|
||||||
|
},
|
||||||
|
term::format::timestamp(issue.timestamp())
|
||||||
|
.dim()
|
||||||
|
.italic()
|
||||||
|
.into(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
fn open<R, G>(
|
fn open<R, G>(
|
||||||
title: Option<Title>,
|
title: Option<Title>,
|
||||||
description: Option<String>,
|
description: Option<String>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue