From b40736d46bb8bdd524d5db4b3e169ad4c68e942f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 31 Oct 2023 16:28:55 +0000 Subject: [PATCH] init binary + initial clap --- Cargo.lock | 9 +++++++++ Cargo.toml | 1 + tools/nymvisor/Cargo.toml | 17 +++++++++++++++++ tools/nymvisor/src/cli/mod.rs | 33 +++++++++++++++++++++++++++++++++ tools/nymvisor/src/main.rs | 12 ++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 tools/nymvisor/Cargo.toml create mode 100644 tools/nymvisor/src/cli/mod.rs create mode 100644 tools/nymvisor/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 0b8497f9a0..296e43934f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7594,6 +7594,15 @@ dependencies = [ "x25519-dalek 2.0.0", ] +[[package]] +name = "nymvisor" +version = "0.1.0" +dependencies = [ + "clap 4.4.7", + "lazy_static", + "nym-bin-common", +] + [[package]] name = "object" version = "0.32.1" diff --git a/Cargo.toml b/Cargo.toml index a8443fc816..3f52fc3a68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,6 +105,7 @@ members = [ "tools/internal/sdk-version-bump", "tools/nym-cli", "tools/nym-nr-query", + "tools/nymvisor", "tools/ts-rs-cli", "wasm/client", # "wasm/full-nym-wasm", diff --git a/tools/nymvisor/Cargo.toml b/tools/nymvisor/Cargo.toml new file mode 100644 index 0000000000..7f5e0349e7 --- /dev/null +++ b/tools/nymvisor/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "nymvisor" +version = "0.1.0" +authors.workspace = true +repository.workspace = true +homepage.workspace = true +documentation.workspace = true +edition.workspace = true +license.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { workspace = true, features = ["derive"] } +lazy_static = { workspace = true } + +nym-bin-common = { path = "../../common/bin-common"} diff --git a/tools/nymvisor/src/cli/mod.rs b/tools/nymvisor/src/cli/mod.rs new file mode 100644 index 0000000000..7cf3aedbef --- /dev/null +++ b/tools/nymvisor/src/cli/mod.rs @@ -0,0 +1,33 @@ +// Copyright 2023 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use clap::{Parser, Subcommand}; +use lazy_static::lazy_static; +use nym_bin_common::bin_info; + +lazy_static! { + pub static ref PRETTY_BUILD_INFORMATION: String = bin_info!().pretty_print(); +} + +// Helper for passing LONG_VERSION to clap +fn pretty_build_info_static() -> &'static str { + &PRETTY_BUILD_INFORMATION +} + +#[derive(Parser, Debug)] +#[clap(author = "Nymtech", version, long_version = pretty_build_info_static(), about)] +pub(crate) struct Cli { + // I doubt we're gonna need any global flags here, but I'm going to leave the the option open + // so that'd be easier to add them later if needed + #[clap(subcommand)] + command: Commands, +} + +#[derive(Subcommand, Debug)] +pub(crate) enum Commands { + Init, + Run, + BuildInfo, + AddUpgrade, + Config, +} diff --git a/tools/nymvisor/src/main.rs b/tools/nymvisor/src/main.rs new file mode 100644 index 0000000000..07b3677b58 --- /dev/null +++ b/tools/nymvisor/src/main.rs @@ -0,0 +1,12 @@ +// Copyright 2023 - Nym Technologies SA +// SPDX-License-Identifier: Apache-2.0 + +use crate::cli::Cli; +use clap::Parser; + +pub(crate) mod cli; + +fn main() { + let args = Cli::parse(); + println!("{args:#?}"); +}