From ea35a37d4cbe6078aad3be8a2050663e907ea529 Mon Sep 17 00:00:00 2001 From: durch Date: Tue, 17 Jan 2023 13:39:49 +0100 Subject: [PATCH] Replace println with eprintln! --- gateway/src/commands/init.rs | 10 +++++----- gateway/src/commands/mod.rs | 8 ++++---- gateway/src/commands/run.rs | 10 +++++----- gateway/src/commands/sign.rs | 6 +++--- gateway/src/commands/upgrade.rs | 6 +++--- gateway/src/node/mod.rs | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gateway/src/commands/init.rs b/gateway/src/commands/init.rs index 426962dc30..653caada49 100644 --- a/gateway/src/commands/init.rs +++ b/gateway/src/commands/init.rs @@ -103,10 +103,10 @@ impl From for OverrideConfig { } pub async fn execute(args: &Init, output: OutputFormat) { - println!("Initialising gateway {}...", args.id); + eprintln!("Initialising gateway {}...", args.id); let already_init = if Config::default_config_file_path(Some(&args.id)).exists() { - println!( + eprintln!( "Gateway \"{}\" was already initialised before! Config information will be \ overwritten (but keys will be kept)!", args.id @@ -146,15 +146,15 @@ pub async fn execute(args: &Init, output: OutputFormat) { ) .expect("Failed to save identity keys"); - println!("Saved identity and mixnet sphinx keypairs"); + eprintln!("Saved identity and mixnet sphinx keypairs"); } let config_save_location = config.get_config_file_save_location(); config .save_to_file(None) .expect("Failed to save the config file"); - println!("Saved configuration file to {:?}", config_save_location); - println!("Gateway configuration completed.\n\n\n"); + eprintln!("Saved configuration file to {:?}", config_save_location); + eprintln!("Gateway configuration completed.\n\n\n"); crate::node::create_gateway(config) .await diff --git a/gateway/src/commands/mod.rs b/gateway/src/commands/mod.rs index 122749624c..4467649b05 100644 --- a/gateway/src/commands/mod.rs +++ b/gateway/src/commands/mod.rs @@ -146,8 +146,8 @@ pub(crate) fn validate_bech32_address_or_exit(address: &str) { bech32_address_validation::try_bech32_decode(address) { let error_message = format!("Error: wallet address decoding failed: {err}").red(); - println!("{}", error_message); - println!("Exiting..."); + eprintln!("{}", error_message); + eprintln!("Exiting..."); process::exit(1); } @@ -155,8 +155,8 @@ pub(crate) fn validate_bech32_address_or_exit(address: &str) { bech32_address_validation::validate_bech32_prefix(&prefix, address) { let error_message = format!("Error: wallet address type is wrong, {err}").red(); - println!("{}", error_message); - println!("Exiting..."); + eprintln!("{}", error_message); + eprintln!("Exiting..."); process::exit(1); } } diff --git a/gateway/src/commands/run.rs b/gateway/src/commands/run.rs index 3198d97029..d9dd27cabb 100644 --- a/gateway/src/commands/run.rs +++ b/gateway/src/commands/run.rs @@ -103,14 +103,14 @@ impl From for OverrideConfig { } fn show_binding_warning(address: String) { - println!("\n##### NOTE #####"); - println!( + eprintln!("\n##### NOTE #####"); + eprintln!( "\nYou are trying to bind to {} - you might not be accessible to other nodes\n\ You can ignore this warning if you're running setup on a local network \n\ or have set a custom 'announce-host'", address ); - println!("\n\n"); + eprintln!("\n\n"); } fn special_addresses() -> Vec<&'static str> { @@ -118,7 +118,7 @@ fn special_addresses() -> Vec<&'static str> { } pub async fn execute(args: &Run, output: OutputFormat) { - println!("Starting gateway {}...", args.id); + eprintln!("Starting gateway {}...", args.id); let mut config = match Config::load_from_file(Some(&args.id)) { Ok(cfg) => cfg, @@ -144,7 +144,7 @@ pub async fn execute(args: &Run, output: OutputFormat) { } let mut gateway = crate::node::create_gateway(config).await; - println!( + eprintln!( "\nTo bond your gateway you will need to install the Nym wallet, go to https://nymtech.net/get-involved and select the Download button.\n\ Select the correct version and install it to your machine. You will need to provide the following: \n "); gateway.print_node_details(output); diff --git a/gateway/src/commands/sign.rs b/gateway/src/commands/sign.rs index c04d937e2c..fcb9f23dee 100644 --- a/gateway/src/commands/sign.rs +++ b/gateway/src/commands/sign.rs @@ -65,18 +65,18 @@ fn print_signed_address(private_key: &identity::PrivateKey, wallet_address: nyxd validate_bech32_address_or_exit(wallet_address.as_ref()); let signature = private_key.sign_text(wallet_address.as_ref()); - println!("The base58-encoded signature on '{wallet_address}' is: {signature}",); + eprintln!("The base58-encoded signature on '{wallet_address}' is: {signature}",); } fn print_signed_text(private_key: &identity::PrivateKey, text: &str) { - println!( + eprintln!( "Signing the text {:?} using your mixnode's Ed25519 identity key...", text ); let signature = private_key.sign_text(text); - println!( + eprintln!( "The base58-encoded signature on '{}' is: {}", text, signature ); diff --git a/gateway/src/commands/upgrade.rs b/gateway/src/commands/upgrade.rs index 6f61401248..b4ea39c493 100644 --- a/gateway/src/commands/upgrade.rs +++ b/gateway/src/commands/upgrade.rs @@ -22,7 +22,7 @@ fn fail_upgrade(from_version: D1, to_version: D2) -> ! } fn print_start_upgrade(from: D1, to: D2) { - println!( + eprintln!( "\n==================\nTrying to upgrade gateway from {} to {} ...", from, to ); @@ -36,7 +36,7 @@ fn print_failed_upgrade(from: D1, to: D2) { } fn print_successful_upgrade(from: D1, to: D2) { - println!( + eprintln!( "Upgrade from {} to {} was successful!\n==================\n", from, to ); @@ -121,7 +121,7 @@ fn do_upgrade(mut config: Config, args: &Upgrade, package_version: Version) { let config_version = parse_config_version(&config); if config_version == package_version { - println!("You're using the most recent version!"); + eprintln!("You're using the most recent version!"); return; } diff --git a/gateway/src/node/mod.rs b/gateway/src/node/mod.rs index 9021c6336b..4ac9f083bc 100644 --- a/gateway/src/node/mod.rs +++ b/gateway/src/node/mod.rs @@ -119,8 +119,8 @@ where let identity_keypair = load_identity_keys(&pathfinder); let Some(address) = self.config.get_wallet_address() else { let error_message = "Error: gateway hasn't set its wallet address".red(); - println!("{error_message}"); - println!("Exiting..."); + eprintln!("{error_message}"); + eprintln!("Exiting..."); process::exit(1); }; // perform extra validation to ensure we have correct prefix