From 4605348d68d5ebc27cf578cbec759b56b0fc1ba7 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Fri, 1 Dec 2023 12:54:42 +0100 Subject: [PATCH] cli: From "tracking" to "seeding" and "following" Split the commands and change the naming. * Tracking a repo is now called "seeding" * Tracking a peer is now called "following" In this commit, we don't change most of the internal code, only the user-facing part. --- radicle-cli/examples/rad-fetch.md | 10 +- .../examples/rad-init-private-clone.md | 4 +- radicle-cli/examples/rad-node.md | 22 +-- radicle-cli/examples/rad-sync-without-node.md | 6 +- radicle-cli/examples/rad-track.md | 8 +- .../workflow/5-patching-maintainer.md | 6 +- radicle-cli/src/commands.rs | 10 +- radicle-cli/src/commands/follow.rs | 124 ++++++++++++ radicle-cli/src/commands/help.rs | 5 +- radicle-cli/src/commands/node.rs | 45 ++--- .../node/{tracking.rs => policies.rs} | 26 +-- radicle-cli/src/commands/seed.rs | 150 ++++++++++++++ radicle-cli/src/commands/track.rs | 185 ------------------ radicle-cli/src/commands/unfollow.rs | 91 +++++++++ radicle-cli/src/commands/untrack.rs | 121 ------------ radicle-cli/src/main.rs | 23 ++- radicle-cli/tests/commands.rs | 2 +- 17 files changed, 438 insertions(+), 400 deletions(-) create mode 100644 radicle-cli/src/commands/follow.rs rename radicle-cli/src/commands/node/{tracking.rs => policies.rs} (71%) create mode 100644 radicle-cli/src/commands/seed.rs delete mode 100644 radicle-cli/src/commands/track.rs create mode 100644 radicle-cli/src/commands/unfollow.rs delete mode 100644 radicle-cli/src/commands/untrack.rs diff --git a/radicle-cli/examples/rad-fetch.md b/radicle-cli/examples/rad-fetch.md index 83362972..c4b32464 100644 --- a/radicle-cli/examples/rad-fetch.md +++ b/radicle-cli/examples/rad-fetch.md @@ -6,15 +6,15 @@ necessary. Instead, we want to fetch the project from the network into our local storage. In this scenario, we know that the project is `rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji`. In order to fetch it, we first -have to track the project. +have to update our seeding policy for the project. ``` -$ rad track rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --no-fetch -✓ Tracking policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'trusted' +$ rad seed rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --no-fetch +✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all' ``` -Now that the project is tracked we can fetch it and we will have it in -our local storage. Note that the `track` command can also be told to fetch +Now that the project is seeding we can fetch it and we will have it in +our local storage. Note that the `seed` command can also be told to fetch by passing the `--fetch` option. ``` diff --git a/radicle-cli/examples/rad-init-private-clone.md b/radicle-cli/examples/rad-init-private-clone.md index 545ef258..7a202ea5 100644 --- a/radicle-cli/examples/rad-init-private-clone.md +++ b/radicle-cli/examples/rad-init-private-clone.md @@ -2,8 +2,8 @@ Given a private repo `rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu` belonging to Alice, Bob tries to fetch it, and even though he's connected to Alice, it fails. ``` ~bob -$ rad track rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu -✓ Tracking policy updated for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu with scope 'trusted' +$ rad seed rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --scope trusted +✓ Seeding policy updated for rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu with scope 'trusted' $ rad ls ``` ``` ~bob (fail) diff --git a/radicle-cli/examples/rad-node.md b/radicle-cli/examples/rad-node.md index 218c0027..ddaecc65 100644 --- a/radicle-cli/examples/rad-node.md +++ b/radicle-cli/examples/rad-node.md @@ -18,22 +18,22 @@ $ rad node status ✓ Node is running. ``` -The node also allows us to query data that it has access too such as -the tracking relationships and the routing table. Before we explore -those commands we'll first track a peer so that we have something to +The node also allows us to query data that it has access to such as +the follow policies and the routing table. Before we explore +those commands we'll first follow a peer so that we have something to see. ``` -$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias Bob -✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (Bob) +$ rad follow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias Bob +✓ Follow policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (Bob) ``` -Now, when we use the `rad node tracking` command we will see -information for repositories that we track -- in this case a +Now, when we use the `rad node seeding` command we will see +information for repositories that we seed -- in this case a repository that was already created: ``` -$ rad node tracking +$ rad node seeding ╭──────────────────────────────────────────────────────╮ │ RID Scope Policy │ ├──────────────────────────────────────────────────────┤ @@ -41,12 +41,10 @@ $ rad node tracking ╰──────────────────────────────────────────────────────╯ ``` -This is the same as using the `--repos` flag, but if we wish to see -which nodes we are specifically tracking, then we use the `--nodes` -flag: +If we wish to see which nodes we are following: ``` -$ rad node tracking --nodes +$ rad node following ╭───────────────────────────────────────────────────────────────────────────╮ │ DID Alias Policy │ ├───────────────────────────────────────────────────────────────────────────┤ diff --git a/radicle-cli/examples/rad-sync-without-node.md b/radicle-cli/examples/rad-sync-without-node.md index a6f32b5f..e7ed8180 100644 --- a/radicle-cli/examples/rad-sync-without-node.md +++ b/radicle-cli/examples/rad-sync-without-node.md @@ -10,9 +10,9 @@ $ rad sync --fetch rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 --seed z6MksmpU5b1dS7oaqF2b ✗ Error: to sync a repository, your node must be running. To start it, run `rad node start` ``` -Note that tracking works fine without a running node: +Note that seeding works fine without a running node: ``` ~alice -$ rad track rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 -✓ Tracking policy updated for rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 with scope 'trusted' +$ rad seed rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 +✓ Seeding policy updated for rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5 with scope 'all' ``` diff --git a/radicle-cli/examples/rad-track.md b/radicle-cli/examples/rad-track.md index 111bc104..5d8c1190 100644 --- a/radicle-cli/examples/rad-track.md +++ b/radicle-cli/examples/rad-track.md @@ -2,13 +2,13 @@ To configure our node's tracking policy, we can use the `rad track` command. For example, let's track a remote node we know about, and alias it to "eve": ``` -$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias eve -✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (eve) +$ rad follow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias eve +✓ Follow policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (eve) ``` Now let's track one of Eve's repositories: ``` -$ rad track rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope trusted --no-fetch -✓ Tracking policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'trusted' +$ rad seed rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope trusted --no-fetch +✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'trusted' ``` diff --git a/radicle-cli/examples/workflow/5-patching-maintainer.md b/radicle-cli/examples/workflow/5-patching-maintainer.md index 12a18320..52a90a75 100644 --- a/radicle-cli/examples/workflow/5-patching-maintainer.md +++ b/radicle-cli/examples/workflow/5-patching-maintainer.md @@ -1,11 +1,11 @@ Back to being the project maintainer. Changes have been proposed by another person (or peer) via a radicle patch. To -follow changes by another, we must 'track' them. +follow changes by another, we must 'follow' them. ``` -$ rad track did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias bob -✓ Tracking policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (bob) +$ rad follow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias bob +✓ Follow policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (bob) ``` Additionally, we need to add a new 'git remote' to our working copy for the diff --git a/radicle-cli/src/commands.rs b/radicle-cli/src/commands.rs index 0deabc29..2ab1455a 100644 --- a/radicle-cli/src/commands.rs +++ b/radicle-cli/src/commands.rs @@ -12,6 +12,8 @@ pub mod rad_cob; pub mod rad_config; #[path = "commands/diff.rs"] pub mod rad_diff; +#[path = "commands/follow.rs"] +pub mod rad_follow; #[path = "commands/fork.rs"] pub mod rad_fork; #[path = "commands/help.rs"] @@ -36,11 +38,11 @@ pub mod rad_path; pub mod rad_publish; #[path = "commands/remote.rs"] pub mod rad_remote; +#[path = "commands/seed.rs"] +pub mod rad_seed; #[path = "commands/self.rs"] pub mod rad_self; #[path = "commands/sync.rs"] pub mod rad_sync; -#[path = "commands/track.rs"] -pub mod rad_track; -#[path = "commands/untrack.rs"] -pub mod rad_untrack; +#[path = "commands/unfollow.rs"] +pub mod rad_unfollow; diff --git a/radicle-cli/src/commands/follow.rs b/radicle-cli/src/commands/follow.rs new file mode 100644 index 00000000..b4514e54 --- /dev/null +++ b/radicle-cli/src/commands/follow.rs @@ -0,0 +1,124 @@ +use std::ffi::OsString; + +use anyhow::anyhow; + +use radicle::node::tracking::Alias; +use radicle::node::{Handle, NodeId}; +use radicle::{prelude::*, Node}; + +use crate::terminal as term; +use crate::terminal::args::{Args, Error, Help}; + +pub const HELP: Help = Help { + name: "follow", + description: "Manage node follow policies", + version: env!("CARGO_PKG_VERSION"), + usage: r#" +Usage + + rad follow [--alias ] [