cli: Add `rad inspect --sigrefs` command

This commit is contained in:
cloudhead 2023-11-15 15:13:46 +01:00
parent d3b0483f42
commit 79644941bd
No known key found for this signature in database
2 changed files with 25 additions and 0 deletions

View File

@ -29,6 +29,13 @@ z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
      └── sigrefs
```
And sigrefs:
```
$ rad inspect --sigrefs
z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi f209c9f68aa689af24220a20462e13ee9dfb2a95
```
Or display the repository identity's payload and delegates:
```

View File

@ -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)? {