From cac6c0aad74a0ea107002c01d302967feacdf6e0 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Mon, 4 Mar 2024 09:48:55 +0000 Subject: [PATCH] cli: add name to `rad seed` output If the name is available to show for the repository -- it may not be if it hasn't been replicated yet -- then add it to the output of the `rad seed` command. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/src/commands/seed.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/radicle-cli/src/commands/seed.rs b/radicle-cli/src/commands/seed.rs index e5a12189..c6df0de9 100644 --- a/radicle-cli/src/commands/seed.rs +++ b/radicle-cli/src/commands/seed.rs @@ -6,7 +6,7 @@ use anyhow::anyhow; use radicle::node::policy; use radicle::node::policy::Scope; use radicle::node::Handle; -use radicle::{prelude::*, Node}; +use radicle::{prelude::*, storage, Node}; use radicle_term::Element as _; use crate::commands::rad_sync as sync; @@ -155,25 +155,32 @@ pub fn delete(rid: RepoId, node: &mut Node, profile: &Profile) -> anyhow::Result pub fn seeding(profile: &Profile) -> anyhow::Result<()> { let store = profile.policies()?; + let storage = &profile.storage; let mut t = term::Table::new(term::table::TableOptions::bordered()); t.header([ term::format::default(String::from("Repository")), + term::format::default(String::from("Name")), term::format::default(String::from("Policy")), term::format::default(String::from("Scope")), ]); t.divider(); - for policy::SeedPolicy { - rid: id, - scope, - policy, - } in store.seed_policies()? - { - let id = id.to_string(); + for policy::SeedPolicy { rid, scope, policy } in store.seed_policies()? { + let id = rid.to_string(); + let name = storage + .repository(rid) + .map_err(storage::RepositoryError::from) + .and_then(|repo| repo.project().map(|proj| proj.name().to_string())) + .unwrap_or_default(); let scope = scope.to_string(); let policy = term::format::policy(&policy); - t.push([term::format::tertiary(id), policy, term::format::dim(scope)]) + t.push([ + term::format::tertiary(id), + name.into(), + policy, + term::format::dim(scope), + ]) } if t.is_empty() {