asimov_cli/commands/
handle.rs1use asimov_id::{Handle, Id, PublicKey, PublicKeyEncoding};
4use clientele::{StandardOptions, crates::clap::Subcommand};
5use core::error::Error;
6use std::path::PathBuf;
7
8#[derive(Debug, Subcommand)]
9pub enum HandleCommand {
10 #[cfg(feature = "unstable")]
11 Add {
12 handle: Handle,
14
15 endpoints: Vec<PublicKey>,
17 },
18
19 Export {},
21
22 #[cfg(feature = "unstable")]
23 Import {
24 inputs: Vec<PathBuf>,
26 },
27
28 #[clap(aliases = ["ls"])]
30 List {},
31
32 #[cfg(feature = "unstable")]
33 #[clap(aliases = ["rm", "delete", "del"])]
34 Remove {
35 handle: Handle,
37
38 endpoints: Vec<PublicKey>,
40 },
41
42 #[clap(aliases = ["lookup"])]
44 Resolve {
45 handle: Id,
47
48 #[clap(short, long)]
50 format: Option<PublicKeyEncoding>,
51 },
52}
53
54impl HandleCommand {
55 pub async fn run(&self, flags: &StandardOptions) -> Result<(), Box<dyn Error>> {
56 match self {
57 #[cfg(feature = "unstable")]
58 HandleCommand::Add { handle, endpoints } => add(handle, endpoints, flags).await,
59
60 HandleCommand::Export {} => export(flags).await,
61
62 #[cfg(feature = "unstable")]
63 HandleCommand::Import { inputs } => import(inputs, flags).await,
64
65 HandleCommand::List {} => list(flags).await,
66
67 #[cfg(feature = "unstable")]
68 HandleCommand::Remove { handle, endpoints } => remove(handle, endpoints, flags).await,
69
70 HandleCommand::Resolve { handle, format } => resolve(handle, format, flags).await,
71 }
72 }
73}
74
75#[cfg(feature = "unstable")]
76mod add;
77#[cfg(feature = "unstable")]
78pub use add::*;
79
80mod export;
81pub use export::*;
82
83#[cfg(feature = "unstable")]
84mod import;
85#[cfg(feature = "unstable")]
86pub use import::*;
87
88mod list;
89pub use list::*;
90
91#[cfg(feature = "unstable")]
92mod remove;
93#[cfg(feature = "unstable")]
94pub use remove::*;
95
96mod resolve;
97pub use resolve::*;