Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: move args to module
✗ CI failure Erik Kundt committed 7 months ago
commit 88a1f452723974f45903e84688bdca36c96a3e37
parent 6eefef57110c58ee745fbc366e327f8e958c925b
1 failed 1 pending (2 total) View logs
2 files changed +43 -37
modified crates/radicle-cli/src/commands/unfollow.rs
@@ -1,44 +1,11 @@
-
use clap::Parser;
+
mod args;

-
use thiserror::Error;
-

-
use radicle::node::{Handle, NodeId};
-
use radicle::prelude::Did;
+
use radicle::node::Handle;

use crate::terminal as term;

-
pub(crate) const ABOUT: &str = "Unfollow a peer";
-

-
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<NodeId, NodeIdParseError> {
-
    value.parse::<Did>().map(NodeId::from).or_else(|did| {
-
        value
-
            .parse::<NodeId>()
-
            .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)]
-
    pub nid: NodeId,
-

-
    /// Verbose output
-
    #[arg(short, long)]
-
    pub verbose: bool,
-
}
+
pub use args::Args;
+
pub(crate) use args::ABOUT;

pub fn run(options: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    let profile = ctx.profile()?;
added crates/radicle-cli/src/commands/unfollow/args.rs
@@ -0,0 +1,39 @@
+
use clap::Parser;
+

+
use thiserror::Error;
+

+
use radicle::node::NodeId;
+
use radicle::prelude::Did;
+

+
pub(crate) const ABOUT: &str = "Unfollow a peer";
+

+
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<NodeId, NodeIdParseError> {
+
    value.parse::<Did>().map(NodeId::from).or_else(|did| {
+
        value
+
            .parse::<NodeId>()
+
            .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)]
+
    pub nid: NodeId,
+

+
    /// Verbose output
+
    #[arg(short, long)]
+
    pub verbose: bool,
+
}