From deaf77e5b429e4b0c3e02038153f671a00c1e192 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Tue, 14 Oct 2025 19:17:56 +0200 Subject: [PATCH] cli/unfollow: Use common DID / NID argument parser --- .../radicle-cli/src/commands/unfollow/args.rs | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/crates/radicle-cli/src/commands/unfollow/args.rs b/crates/radicle-cli/src/commands/unfollow/args.rs index 5f50efbf..75a24597 100644 --- a/crates/radicle-cli/src/commands/unfollow/args.rs +++ b/crates/radicle-cli/src/commands/unfollow/args.rs @@ -1,9 +1,8 @@ use clap::Parser; -use thiserror::Error; - use radicle::node::NodeId; -use radicle::prelude::Did; + +use crate::terminal as term; pub(crate) const ABOUT: &str = "Unfollow a peer"; @@ -11,26 +10,11 @@ const LONG_ABOUT: &str = r#" The `unfollow` command takes a Node ID, optionally in DID format, and removes the follow policy for that peer."#; -#[derive(Debug, Error)] -#[error("invalid Node ID specified (Node ID parsing failed with: '{nid}', DID parsing failed with: '{did}'))")] -struct NodeIdParseError { - did: radicle::identity::did::DidError, - nid: radicle::crypto::PublicKeyError, -} - -fn parse_nid(value: &str) -> Result { - value.parse::().map(NodeId::from).or_else(|did| { - value - .parse::() - .map_err(|nid| NodeIdParseError { nid, did }) - }) -} - #[derive(Debug, Parser)] #[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)] pub struct Args { /// Node ID (optionally in DID format) of the peer to unfollow - #[arg(value_name = "NID", value_parser = parse_nid)] + #[arg(value_name = "NID", value_parser = term::args::parse_nid)] pub(super) nid: NodeId, /// Verbose output