diff --git a/radicle-cli/examples/rad-sync.md b/radicle-cli/examples/rad-sync.md index 8b11248a..4b1e0f77 100644 --- a/radicle-cli/examples/rad-sync.md +++ b/radicle-cli/examples/rad-sync.md @@ -7,6 +7,18 @@ 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 ``` +If we check the sync status, we see that our peers are out of sync: + +``` +$ rad sync status +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ ● NID Address Status At Timestamp │ +├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ ● z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z eve.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │ +│ ● z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk bob.radicle.xyz:8776 out-of-sync f209c9f [ ... ] │ +╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +``` + Now let's run `rad sync`. This will announce the issue refs to the network and wait for nodes to announce that they have fetched those refs. @@ -57,3 +69,15 @@ $ rad sync --fetch --replicas 1 ✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6Mkux1…nVhib7Z.. ✓ Fetched repository from 1 seed(s) ``` + +We can check the sync status again to make sure everything's in sync: + +``` +$ rad sync status +╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ ● NID Address Status At Timestamp │ +├────────────────────────────────────────────────────────────────────────────────────────────────────────────┤ +│ ● z6Mkux1aUQD2voWWukVb5nNUR7thrHveQG4pDQua8nVhib7Z eve.radicle.xyz:8776 synced 9f615f9 [ ... ] │ +│ ● z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk bob.radicle.xyz:8776 synced 9f615f9 [ ... ] │ +╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +``` diff --git a/radicle-cli/src/commands/sync.rs b/radicle-cli/src/commands/sync.rs index 74f14e62..7de8c26e 100644 --- a/radicle-cli/src/commands/sync.rs +++ b/radicle-cli/src/commands/sync.rs @@ -4,12 +4,14 @@ use std::time; use anyhow::{anyhow, Context as _}; use radicle::node; -use radicle::node::{FetchResult, FetchResults, Handle as _, Node}; +use radicle::node::{FetchResult, FetchResults, Handle as _, Node, SyncStatus}; use radicle::prelude::{Id, NodeId, Profile}; use radicle::storage::{ReadRepository, ReadStorage}; +use radicle_term::Element; use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; +use crate::terminal::{Table, TableOptions}; pub const HELP: Help = Help { name: "sync", @@ -20,6 +22,7 @@ Usage rad sync [--fetch | --announce] [] [