cli: Improve `rad sync status` output

To make it less confusing, clearly mark the local node and don't show
sync status for it.
This commit is contained in:
cloudhead 2023-12-18 13:50:12 +01:00
parent 5e3990d411
commit 67c950954d
No known key found for this signature in database
3 changed files with 19 additions and 23 deletions

View File

@ -7,18 +7,16 @@ For instance let's create an issue and sync it with the network:
$ rad issue open --title "Test `rad sync`" --description "Check that the command works" -q --no-announce $ rad issue open --title "Test `rad sync`" --description "Check that the command works" -q --no-announce
``` ```
If we check the sync status, we see that our peers are out of sync: If we check the sync status, we see that our peers are out of sync.
Our own node is also out of sync, since we used `--no-announce`.
It isn't aware of the updates to the repo.
``` ```
$ rad sync status --sort-by alias $ rad sync status --sort-by alias
╭──────────────────────────────────────────────────────────────────────────────────────────╮ ╭──────────────────────────────────────────────────────────────────────────────────────────╮
│ ● NID Alias Address Status At Timestamp │ │ ● Node Address Status Tip Timestamp │
├──────────────────────────────────────────────────────────────────────────────────────────┤ ├──────────────────────────────────────────────────────────────────────────────────────────┤
│ ● z6MknSL…StBU8Vi alice alice.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │ │ ● alice (you) alice.radicle.xyz:8776 f209c9f [ ... ] │
│ ● z6Mkt67…v4N1tRk bob bob.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │ │ ● bob z6Mkt67…v4N1tRk bob.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │
│ ● z6Mkux1…nVhib7Z eve eve.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │ │ ● eve z6Mkux1…nVhib7Z eve.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │
╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╰──────────────────────────────────────────────────────────────────────────────────────────╯
``` ```
@ -78,10 +76,10 @@ We can check the sync status again to make sure everything's in sync:
``` ```
$ rad sync status --sort-by alias $ rad sync status --sort-by alias
╭─────────────────────────────────────────────────────────────────────────────────────╮ ╭─────────────────────────────────────────────────────────────────────────────────────╮
│ ● NID Alias Address Status At Timestamp │ │ ● Node Address Status Tip Timestamp │
├─────────────────────────────────────────────────────────────────────────────────────┤ ├─────────────────────────────────────────────────────────────────────────────────────┤
│ ● z6MknSL…StBU8Vi alice alice.radicle.xyz:8776 synced 9f615f9 [ ... ] │ │ ● alice (you) alice.radicle.xyz:8776 9f615f9 [ ... ] │
│ ● z6Mkt67…v4N1tRk bob bob.radicle.xyz:8776 synced 9f615f9 [ ... ] │ │ ● bob z6Mkt67…v4N1tRk bob.radicle.xyz:8776 synced 9f615f9 [ ... ] │
│ ● z6Mkux1…nVhib7Z eve eve.radicle.xyz:8776 synced 9f615f9 [ ... ] │ │ ● eve z6Mkux1…nVhib7Z eve.radicle.xyz:8776 synced 9f615f9 [ ... ] │
╰─────────────────────────────────────────────────────────────────────────────────────╯ ╰─────────────────────────────────────────────────────────────────────────────────────╯
``` ```

View File

@ -9,7 +9,7 @@ $ rad ls
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
``` ```
We could stop seeding it if didn't want other nodes to fetch it from us: We could stop seeding it if we didn't want other nodes to fetch it from us:
``` ```
$ rad seed --delete rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji $ rad seed --delete rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji

View File

@ -15,6 +15,7 @@ use radicle_term::Element;
use crate::terminal as term; use crate::terminal as term;
use crate::terminal::args::{Args, Error, Help}; use crate::terminal::args::{Args, Error, Help};
use crate::terminal::format::Author;
use crate::terminal::{Table, TableOptions}; use crate::terminal::{Table, TableOptions};
pub const HELP: Help = Help { pub const HELP: Help = Help {
@ -316,11 +317,11 @@ fn sync_status(
table.push([ table.push([
term::format::dim(String::from("")).into(), term::format::dim(String::from("")).into(),
term::format::bold(String::from("NID")).into(), term::format::bold(String::from("Node")).into(),
term::format::bold(String::from("Alias")).into(), term::Label::blank(),
term::format::bold(String::from("Address")).into(), term::format::bold(String::from("Address")).into(),
term::format::bold(String::from("Status")).into(), term::format::bold(String::from("Status")).into(),
term::format::bold(String::from("At")).into(), term::format::bold(String::from("Tip")).into(),
term::format::bold(String::from("Timestamp")).into(), term::format::bold(String::from("Timestamp")).into(),
]); ]);
table.divider(); table.divider();
@ -331,13 +332,13 @@ fn sync_status(
let (icon, status, head, time) = match seed.sync { let (icon, status, head, time) = match seed.sync {
Some(SyncStatus::Synced { at }) => ( Some(SyncStatus::Synced { at }) => (
term::format::positive(""), term::format::positive(""),
term::format::positive("synced"), term::format::positive(if seed.nid != local { "synced" } else { "" }),
term::format::oid(at.oid), term::format::oid(at.oid),
term::format::timestamp(at.timestamp), term::format::timestamp(at.timestamp),
), ),
Some(SyncStatus::OutOfSync { remote, .. }) => ( Some(SyncStatus::OutOfSync { remote, .. }) => (
term::format::negative(""), term::format::negative(""),
term::format::negative("out-of-sync"), term::format::negative(if seed.nid != local { "out-of-sync" } else { "" }),
term::format::oid(remote.oid), term::format::oid(remote.oid),
term::format::timestamp(remote.timestamp), term::format::timestamp(remote.timestamp),
), ),
@ -355,15 +356,12 @@ fn sync_status(
.map(|a| a.addr.to_string()) .map(|a| a.addr.to_string())
.unwrap_or_default() .unwrap_or_default()
.into(); .into();
let alias = aliases let (alias, nid) = Author::new(&seed.nid, profile).labels();
.alias(&seed.nid)
.map(|a| a.to_string())
.unwrap_or_default();
table.push([ table.push([
icon.into(), icon.into(),
term::format::primary(term::format::node(&seed.nid)).into(), alias,
term::format::primary(alias).dim().into(), nid,
addr, addr,
status.into(), status.into(),
term::format::secondary(head).into(), term::format::secondary(head).into(),