5f4926dd49
* fixed all uses of deprecated clap methods * updated all uses of clap to 4.0 * unified obtaining build information * moved around the imports * Moved all nym-api arguments to ApiArgs and simplified parsing * Using common shutdown signal code * Using clap for parsing Vec<Url> * stricter validation of socks5-client arguments * ibid for the native client * ibid for the gateway * ibid for the mixnode * clippy
75 lines
1.5 KiB
Rust
75 lines
1.5 KiB
Rust
// Copyright 2020-2023 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
#[macro_use]
|
|
extern crate rocket;
|
|
|
|
use ::config::defaults::setup_env;
|
|
use build_information::BinaryBuildInformation;
|
|
use clap::{crate_version, Parser};
|
|
use lazy_static::lazy_static;
|
|
use logging::setup_logging;
|
|
|
|
mod commands;
|
|
mod config;
|
|
mod node;
|
|
|
|
lazy_static! {
|
|
pub static ref PRETTY_BUILD_INFORMATION: String =
|
|
BinaryBuildInformation::new(env!("CARGO_PKG_VERSION")).pretty_print();
|
|
}
|
|
|
|
// Helper for passing LONG_VERSION to clap
|
|
fn pretty_build_info_static() -> &'static str {
|
|
&PRETTY_BUILD_INFORMATION
|
|
}
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author = "Nymtech", version, about, long_version = pretty_build_info_static())]
|
|
struct Cli {
|
|
/// Path pointing to an env file that configures the mixnode.
|
|
#[clap(short, long)]
|
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
|
|
|
#[clap(subcommand)]
|
|
command: commands::Commands,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
setup_logging();
|
|
println!("{}", banner());
|
|
|
|
let args = Cli::parse();
|
|
setup_env(args.config_env_file.as_ref());
|
|
commands::execute(args).await;
|
|
}
|
|
|
|
fn banner() -> String {
|
|
format!(
|
|
r#"
|
|
|
|
_ __ _ _ _ __ ___
|
|
| '_ \| | | | '_ \ _ \
|
|
| | | | |_| | | | | | |
|
|
|_| |_|\__, |_| |_| |_|
|
|
|___/
|
|
|
|
(mixnode - version {:})
|
|
|
|
"#,
|
|
crate_version!()
|
|
)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use clap::CommandFactory;
|
|
|
|
#[test]
|
|
fn verify_cli() {
|
|
Cli::command().debug_assert();
|
|
}
|
|
}
|