Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
cli: Add rad inspect --sigrefs command
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Nov 17, 2023
1 parent d3b0483 commit 7964494
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions radicle-cli/examples/rad-inspect.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
      └── sigrefs
```

And sigrefs:

```
$ rad inspect --sigrefs
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi f209c9f68aa689af24220a20462e13ee9dfb2a95
```

Or display the repository identity's payload and delegates:

```
Expand Down
18 changes: 18 additions & 0 deletions radicle-cli/src/commands/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -52,6 +54,7 @@ pub enum Target {
Delegates,
Identity,
Visibility,
Sigrefs,
Policy,
History,
#[default]
Expand Down Expand Up @@ -95,6 +98,9 @@ impl Args for Options {
Long("identity") => {
target = Target::Identity;
}
Long("sigrefs") => {
target = Target::Sigrefs;
}
Long("rid") => {
target = Target::RepoId;
}
Expand Down Expand Up @@ -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)? {
Expand Down

0 comments on commit 7964494

Please sign in to comment.