refactor(rust): update message send command
use clap::Args;
-use std::str::FromStr;
use ockam::{Context, TcpTransport};
use ockam_multiaddr::MultiAddr;
@@ -8,7 +7,9 @@ use crate::util::embedded_node;
#[derive(Clone, Debug, Args)]
pub struct SendCommand {
- addr: String,
+ /// The route to send the message to (required)
+ #[clap(short, long, value_name = "ROUTE")]
+ to: MultiAddr,
message: String,
}
@@ -21,8 +22,7 @@ impl SendCommand {
async fn send_message(mut ctx: Context, cmd: SendCommand) -> anyhow::Result<()> {
let _tcp = TcpTransport::create(&ctx).await?;
- let addr = MultiAddr::from_str(&cmd.addr)?;
- if let Some(route) = ockam_api::multiaddr_to_route(&addr) {
+ if let Some(route) = ockam_api::multiaddr_to_route(&cmd.to) {
ctx.send(route, cmd.message).await?;
let message = ctx.receive::<String>().await?;
println!("{}", message);
