From 79644941bdfd595456e3b66a7d6630fcac9c7699 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Wed, 15 Nov 2023 15:13:46 +0100 Subject: [PATCH] cli: Add `rad inspect --sigrefs` command --- radicle-cli/examples/rad-inspect.md | 7 +++++++ radicle-cli/src/commands/inspect.rs | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/radicle-cli/examples/rad-inspect.md b/radicle-cli/examples/rad-inspect.md index 6101f81c7..493eec682 100644 --- a/radicle-cli/examples/rad-inspect.md +++ b/radicle-cli/examples/rad-inspect.md @@ -29,6 +29,13 @@ z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi       └── sigrefs ``` +And sigrefs: + +``` +$ rad inspect --sigrefs +z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi f209c9f68aa689af24220a20462e13ee9dfb2a95 +``` + Or display the repository identity's payload and delegates: ``` diff --git a/radicle-cli/src/commands/inspect.rs b/radicle-cli/src/commands/inspect.rs index 257341a65..db281c35c 100644 --- a/radicle-cli/src/commands/inspect.rs +++ b/radicle-cli/src/commands/inspect.rs @@ -12,6 +12,7 @@ use radicle::identity::Id; use radicle::identity::Identity; use radicle::node::tracking::Policy; use radicle::node::AliasStore as _; +use radicle::storage::refs::RefsAt; use radicle::storage::{ReadRepository, ReadStorage}; use crate::terminal as term; @@ -36,6 +37,7 @@ Options --rid Return the repository identifier (RID) --payload Inspect the repository's identity payload --refs Inspect the repository's refs on the local device + --sigrefs Inspect the values of `rad/sigrefs` for all remotes of this repository --identity Inspect the identity document --visibility Inspect the repository's visibility --delegates Inspect the repository's delegates @@ -52,6 +54,7 @@ pub enum Target { Delegates, Identity, Visibility, + Sigrefs, Policy, History, #[default] @@ -95,6 +98,9 @@ impl Args for Options { Long("identity") => { target = Target::Identity; } + Long("sigrefs") => { + target = Target::Sigrefs; + } Long("rid") => { target = Target::RepoId; } @@ -159,6 +165,18 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> { colorizer().colorize_json_str(&serde_json::to_string_pretty(&project.doc)?)? ); } + Target::Sigrefs => { + for remote in repo.remote_ids()? { + let remote = remote?; + let refs = RefsAt::new(&repo, remote)?; + + println!( + "{:<48} {}", + term::format::tertiary(remote.to_human()), + term::format::secondary(refs.at) + ); + } + } Target::Policy => { let tracking = profile.tracking()?; if let Some(repo) = tracking.repo_policy(&rid)? {