diff --git a/Cargo.lock b/Cargo.lock index f520128a43..1da04e0314 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7603,6 +7603,7 @@ dependencies = [ "lazy_static", "nix 0.27.1", "nym-bin-common", + "tokio", ] [[package]] diff --git a/tools/nymvisor/Cargo.toml b/tools/nymvisor/Cargo.toml index 931496a834..2fc8b56b71 100644 --- a/tools/nymvisor/Cargo.toml +++ b/tools/nymvisor/Cargo.toml @@ -15,5 +15,6 @@ anyhow = { workspace = true } clap = { workspace = true, features = ["derive"] } lazy_static = { workspace = true } nix = "0.27.1" +tokio = { workspace = true, features = ["rt", "macros", "signal", "process"] } nym-bin-common = { path = "../../common/bin-common", features = ["output_format"] } diff --git a/tools/nymvisor/src/cli/add_upgrade.rs b/tools/nymvisor/src/cli/add_upgrade.rs index 090dd1927a..0747cbbcc2 100644 --- a/tools/nymvisor/src/cli/add_upgrade.rs +++ b/tools/nymvisor/src/cli/add_upgrade.rs @@ -1,9 +1,12 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use nym_bin_common::output_format::OutputFormat; + #[derive(clap::Args, Debug)] pub(crate) struct Args { - // + #[clap(short, long, default_value_t = OutputFormat::default())] + output: OutputFormat, } pub(crate) fn execute(args: Args) -> anyhow::Result<()> { diff --git a/tools/nymvisor/src/cli/config.rs b/tools/nymvisor/src/cli/config.rs index 540752615e..bb545e3ea1 100644 --- a/tools/nymvisor/src/cli/config.rs +++ b/tools/nymvisor/src/cli/config.rs @@ -1,9 +1,12 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use nym_bin_common::output_format::OutputFormat; + #[derive(clap::Args, Debug)] pub(crate) struct Args { - // + #[clap(short, long, default_value_t = OutputFormat::default())] + output: OutputFormat, } pub(crate) fn execute(args: Args) -> anyhow::Result<()> { diff --git a/tools/nymvisor/src/cli/init.rs b/tools/nymvisor/src/cli/init.rs index 5b16fd2a3b..7663483ddf 100644 --- a/tools/nymvisor/src/cli/init.rs +++ b/tools/nymvisor/src/cli/init.rs @@ -1,9 +1,12 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use nym_bin_common::output_format::OutputFormat; + #[derive(clap::Args, Debug)] pub(crate) struct Args { - // + #[clap(short, long, default_value_t = OutputFormat::default())] + output: OutputFormat, } pub(crate) fn execute(args: Args) -> anyhow::Result<()> { diff --git a/tools/nymvisor/src/cli/mod.rs b/tools/nymvisor/src/cli/mod.rs index 2d833379e8..4f7a81d9dd 100644 --- a/tools/nymvisor/src/cli/mod.rs +++ b/tools/nymvisor/src/cli/mod.rs @@ -43,9 +43,18 @@ impl Cli { #[derive(Subcommand, Debug)] pub(crate) enum Commands { + /// TODO: document the command Init(init::Args), + + /// TODO: document the command Run(run::Args), + + /// TODO: document the command BuildInfo(build_info::Args), + + /// TODO: document the command AddUpgrade(add_upgrade::Args), + + /// TODO: document the command Config(config::Args), } diff --git a/tools/nymvisor/src/cli/run.rs b/tools/nymvisor/src/cli/run.rs index e0b9bc167e..86e413a58f 100644 --- a/tools/nymvisor/src/cli/run.rs +++ b/tools/nymvisor/src/cli/run.rs @@ -1,6 +1,8 @@ // Copyright 2023 - Nym Technologies SA // SPDX-License-Identifier: Apache-2.0 +use tokio::runtime; + #[derive(clap::Args, Debug)] pub(crate) struct Args { #[clap(trailing_var_arg = true)] @@ -9,14 +11,20 @@ pub(crate) struct Args { } pub(crate) fn execute(args: Args) -> anyhow::Result<()> { - println!("run"); + // TODO: experiment with the minimal runtime + let rt = runtime::Builder::new_current_thread().enable_io().build()?; - let mut child = std::process::Command::new("echo") - .args(args.daemon_args) - .spawn()?; + // spawn the root task + rt.block_on(async { + println!("run"); - let status = child.wait()?; + let mut child = tokio::process::Command::new("echo") + .args(args.daemon_args) + .spawn()?; - println!("{:?}", status); - Ok(()) + let status = child.wait().await?; + + println!("{:?}", status); + Ok(()) + }) }