Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
Add repository names to rad seed output
Archived did:key:z6Mkgfwr...BYQp opened 2 years ago

… and sort table rows. Makes it more usable and similar to rad ls output.

1 file changed +24 -13 8928c5ee e3f0fdce
modified radicle-cli/src/commands/seed.rs
@@ -174,32 +174,43 @@ pub fn delete(rid: RepoId, node: &mut Node, profile: &Profile) -> anyhow::Result
}

pub fn seeding(profile: &Profile) -> anyhow::Result<()> {
-
    let store = profile.policies()?;
+
    let policies = profile.policies()?;
+
    let storage = &profile.storage;
    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.divider();
+
    let mut rows = Vec::new();

    for policy::SeedPolicy {
        rid: id,
        scope,
        policy,
-
    } in store.seed_policies()?
+
    } in policies.seed_policies()?
    {
-
        let id = id.to_string();
+
        let repo = storage.repository(id)?;
        let scope = scope.to_string();
        let policy = policy.to_string();

-
        t.push([
-
            term::format::highlight(id),
+
        rows.push([
+
            term::format::bold(repo.identity_doc()?.project()?.name().to_owned()),
+
            term::format::tertiary(id.urn()),
            term::format::secondary(scope),
            term::format::secondary(policy),
-
        ])
+
        ]);
+
    }
+
    rows.sort();
+

+
    if rows.is_empty() {
+
        term::print(term::format::italic("Nothing to show."));
+
    } else {
+
        t.push([
+
            term::format::default("Name".into()),
+
            term::format::default("RID".into()),
+
            term::format::default("Scope".into()),
+
            term::format::default("Policy".into()),
+
        ]);
+
        t.divider();
+
        t.extend(rows);
+
        t.print();
    }
-
    t.print();

    Ok(())
}