From f6e2de30ca40402aedc8c062ef0bf59e05f51919 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Wed, 13 Dec 2023 19:49:52 +0000 Subject: [PATCH] cli: move following behaviour to `rad follow` To keep behaviour consistently under subcommands, move the `rad node following` behaviour under `rad follow`. When an `` isn't provided then the followed nodes are listed. This includes filtering by alias, when `--alias` is used. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/examples/rad-node.md | 2 +- radicle-cli/examples/rad-seed-and-follow.md | 11 +++ radicle-cli/src/commands/follow.rs | 94 +++++++++++++++++---- radicle-cli/src/commands/node.rs | 6 -- radicle-cli/src/commands/node/policies.rs | 36 +------- 5 files changed, 92 insertions(+), 57 deletions(-) diff --git a/radicle-cli/examples/rad-node.md b/radicle-cli/examples/rad-node.md index 379abbef..638733d8 100644 --- a/radicle-cli/examples/rad-node.md +++ b/radicle-cli/examples/rad-node.md @@ -44,7 +44,7 @@ $ rad node seeding If we wish to see which nodes we are following: ``` -$ rad node following +$ rad follow ╭───────────────────────────────────────────────────────────────────────────╮ │ DID Alias Policy │ ├───────────────────────────────────────────────────────────────────────────┤ diff --git a/radicle-cli/examples/rad-seed-and-follow.md b/radicle-cli/examples/rad-seed-and-follow.md index 5d01db94..03280d63 100644 --- a/radicle-cli/examples/rad-seed-and-follow.md +++ b/radicle-cli/examples/rad-seed-and-follow.md @@ -7,6 +7,17 @@ $ rad follow did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk --alias ev ✓ Follow policy updated for z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk (eve) ``` +We can list the followed peers by omitting the DID: + +``` +$ rad follow +╭───────────────────────────────────────────────────────────────────────────╮ +│ DID Alias Policy │ +├───────────────────────────────────────────────────────────────────────────┤ +│ did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk eve allow │ +╰───────────────────────────────────────────────────────────────────────────╯ +``` + Now let's seed one of Eve's repositories: ``` diff --git a/radicle-cli/src/commands/follow.rs b/radicle-cli/src/commands/follow.rs index a2fa1eaa..6fde950b 100644 --- a/radicle-cli/src/commands/follow.rs +++ b/radicle-cli/src/commands/follow.rs @@ -2,8 +2,9 @@ use std::ffi::OsString; use anyhow::anyhow; -use radicle::node::{Alias, Handle, NodeId}; +use radicle::node::{policy, Alias, AliasStore, Handle, NodeId}; use radicle::{prelude::*, Node}; +use radicle_term::{Element as _, Paint, Table}; use crate::terminal as term; use crate::terminal::args::{Args, Error, Help}; @@ -15,10 +16,12 @@ pub const HELP: Help = Help { usage: r#" Usage - rad follow [--alias ] [