radicle_cli/commands/follow/
args.rs1use clap::Parser;
2
3use radicle::node::{Alias, NodeId};
4
5use crate::terminal as term;
6
7const ABOUT: &str = "Manage node follow policies";
8
9const LONG_ABOUT: &str = r#"
10The `follow` command will print all nodes being followed, optionally filtered by alias, if no
11Node ID is provided.
12Otherwise, it takes a Node ID, optionally in DID format, and updates the follow policy
13for that peer, optionally giving the peer the alias provided.
14"#;
15
16#[derive(Parser, Debug)]
17#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
18pub struct Args {
19 #[arg(value_parser = term::args::parse_nid)]
21 nid: Option<NodeId>,
22
23 #[arg(long)]
25 alias: Option<Alias>,
26
27 #[arg(long, short)]
29 verbose: bool,
30}
31
32pub(super) enum Operation {
33 Follow {
34 nid: NodeId,
35 alias: Option<Alias>,
36 #[allow(dead_code)]
37 verbose: bool,
38 },
39 List {
40 alias: Option<Alias>,
41 #[allow(dead_code)]
42 verbose: bool,
43 },
44}
45
46impl From<Args> for Operation {
47 fn from(
48 Args {
49 nid,
50 alias,
51 verbose,
52 }: Args,
53 ) -> Self {
54 match nid {
55 Some(nid) => Self::Follow {
56 nid,
57 alias,
58 verbose,
59 },
60 None => Self::List { alias, verbose },
61 }
62 }
63}