Skip to main content

asimov_cli/commands/
message.rs

1// This is free and unencumbered software released into the public domain.
2
3use asimov_protocol::Topic;
4use clientele::{StandardOptions, crates::clap::Subcommand};
5use core::error::Error;
6use std::string::String;
7
8#[derive(Debug, Subcommand)]
9pub enum MessageCommand {
10    /// Send a message to a peer
11    Send {
12        /// The recipient for the message
13        recipient: Topic,
14
15        /// The message to send
16        message: String,
17
18        /// A peer ticket for bootstrapping
19        #[arg(long)]
20        ticket: Option<String>,
21    },
22}
23
24impl MessageCommand {
25    pub async fn run(&self, flags: &StandardOptions) -> Result<(), Box<dyn Error>> {
26        use MessageCommand::*;
27        match self {
28            Send {
29                recipient,
30                message,
31                ticket,
32            } => send(recipient, message, ticket, flags).await,
33        }
34    }
35}
36
37mod send;
38pub use send::*;