Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Replace manual pushing with Table::extend()
Matthias Beyer committed 8 months ago
commit d2c2115db09ebdfe467dda7d006636f2eaff9b05
parent eabfd022c792eeb4d1406b5851f58b6349f1e2fd
1 file changed +36 -24
modified crates/radicle-cli/src/commands/issue.rs
@@ -783,7 +783,7 @@ where
    ]);
    table.divider();

-
    for (id, issue) in all {
+
    table.extend(all.into_iter().map(|(id, issue)| {
        let assigned: String = issue
            .assignees()
            .map(|did| {
@@ -800,34 +800,46 @@ where
        let author = issue.author().id;
        let (alias, did) = Author::new(&author, profile, false).labels();

-
        table.push([
-
            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(),
-
        ]);
-
    }
+
        mk_issue_row(id, issue, assigned, labels, alias, did)
+
    }));
+

    table.print();

    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>(
    title: Option<Title>,
    description: Option<String>,