use crate::util::foreground_args::ForegroundArgs;
use crate::util::{embedded_node_that_is_not_stopped, local_cmd};
use crate::{Command, CommandGlobalOpts};
use async_trait::async_trait;
use clap::Args;
use ockam_node::Context;
use tracing::instrument;
#[derive(Clone, Debug, Args)]
pub struct CreateCommand {
#[command(flatten)]
pub foreground_args: ForegroundArgs,
#[arg(
display_order = 900,
long = "udp",
id = "UDP_SOCKET_ADDRESS",
default_value = "0.0.0.0:4000"
)]
pub udp_address: String,
#[arg(
display_order = 900,
long = "healthcheck",
id = "TCP_SOCKET_ADDRESS",
default_value = "0.0.0.0:4001"
)]
pub healthcheck_address: String,
}
#[async_trait]
impl Command for CreateCommand {
const NAME: &'static str = "rendezvous create";
#[instrument(skip_all)]
fn run(self, opts: CommandGlobalOpts) -> miette::Result<()> {
local_cmd(embedded_node_that_is_not_stopped(
opts.rt.clone(),
|ctx| async move { self.foreground_mode(&ctx, opts).await },
))
}
async fn async_run(self, ctx: &Context, opts: CommandGlobalOpts) -> crate::Result<()> {
self.foreground_mode(ctx, opts).await?;
Ok(())
}
}