From fd985c53c2f78bb79e3bef4a426bd17ebf427655 Mon Sep 17 00:00:00 2001 From: abhi3700 Date: Mon, 5 Feb 2024 21:35:19 +0530 Subject: [PATCH] Remove show flag from config command `$ pulsar config -s` has been replaced with `$ pulsar config` to show the already set config params/fields details. --- pulsar/src/commands/config.rs | 28 ++++++++++++++++------------ pulsar/src/main.rs | 9 +++------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pulsar/src/commands/config.rs b/pulsar/src/commands/config.rs index 1cb9b518..49f517f9 100644 --- a/pulsar/src/commands/config.rs +++ b/pulsar/src/commands/config.rs @@ -12,7 +12,7 @@ //! //! ### Show //! ```bash -//! $ pulsar config -s +//! $ pulsar config //! Current Config set as: //! { //! "chain": "Gemini3g", @@ -77,7 +77,6 @@ use crate::utils::{create_or_move_data, reward_address_parser, size_parser}; // function for config cli command pub(crate) async fn config( - show: bool, chain: Option, farm_size: Option, reward_address: Option, @@ -95,16 +94,12 @@ pub(crate) async fn config( // Load the current configuration let mut config: Config = parse_config()?; - if show { - // Display the current configuration as JSON - // Serialize `config` to a pretty-printed JSON string - let serialized = serde_json::to_string_pretty(&config)?; - println!( - "Current Config set as: \n{}\nin file: {:?}", - serialized, - config_path.to_str().expect("Expected stringified config path") - ); - } else { + if chain.is_some() + || farm_size.is_some() + || reward_address.is_some() + || node_dir.is_some() + || farm_dir.is_some() + { // no options provided if chain.is_none() && farm_size.is_none() @@ -162,6 +157,15 @@ pub(crate) async fn config( // Save the updated configuration back to the file fs::write(config_path, toml::to_string(&config)?)?; + } else { + // Display the current configuration as JSON + // Serialize `config` to a pretty-printed JSON string + let serialized = serde_json::to_string_pretty(&config)?; + println!( + "Current Config already set as: \n{}\nin file: {:?}", + serialized, + config_path.to_str().expect("Expected stringified config path") + ); } Ok(()) diff --git a/pulsar/src/main.rs b/pulsar/src/main.rs index 63a4ec85..7ee9a211 100644 --- a/pulsar/src/main.rs +++ b/pulsar/src/main.rs @@ -73,8 +73,6 @@ enum Commands { about = "set the config params: chain, farm-size, reward-address, node-dir, farm-dir" )] Config { - #[arg(short, long, action)] - show: bool, #[arg(short, long, action)] chain: Option, #[arg(short, long, action)] @@ -106,8 +104,8 @@ async fn main() -> Result<(), Report> { Some(Commands::Wipe { farmer, node }) => { wipe_config(farmer, node).await.suggestion(support_message())?; } - Some(Commands::Config { chain, show, farm_size, reward_address, node_dir, farm_dir }) => { - config(show, chain, farm_size, reward_address, node_dir, farm_dir) + Some(Commands::Config { chain, farm_size, reward_address, node_dir, farm_dir }) => { + config(chain, farm_size, reward_address, node_dir, farm_dir) .await .suggestion(support_message())?; } @@ -200,7 +198,7 @@ async fn arrow_key_mode() -> Result<(), Report> { info().await.suggestion(support_message())?; } 4 => { - config(true, None, None, None, None, None).await.suggestion(support_message())?; + config(None, None, None, None, None).await.suggestion(support_message())?; } 5 => { open_log_dir().suggestion(support_message())?; @@ -249,7 +247,6 @@ impl std::fmt::Display for Commands { Commands::Info => write!(f, "info"), Commands::Init => write!(f, "init"), Commands::Config { - show: _, chain: _, farm_size: _, reward_address: _,