From e20712c2f07ce178e2b807c79610641c72892501 Mon Sep 17 00:00:00 2001 From: feliciss <22887031+feliciss@users.noreply.github.com> Date: Sun, 25 Jun 2023 20:46:07 -0600 Subject: [PATCH] [cli] return a string for init command. (#347) Co-authored-by: Feliciss <10203-feliciss@users.noreply.0xacab.org> --- crates/rooch/src/commands/init.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/rooch/src/commands/init.rs b/crates/rooch/src/commands/init.rs index 17818bfe8..08e293bb5 100644 --- a/crates/rooch/src/commands/init.rs +++ b/crates/rooch/src/commands/init.rs @@ -20,8 +20,8 @@ pub struct Init { } #[async_trait] -impl CommandAction<()> for Init { - async fn execute(self) -> RoochResult<()> { +impl CommandAction for Init { + async fn execute(self) -> RoochResult { let client_config_path = match self.context_options.config_dir { Some(v) => { if !v.exists() { @@ -31,7 +31,7 @@ impl CommandAction<()> for Init { } None => rooch_config_dir()?.join(ROOCH_CLIENT_CONFIG), }; - // Prompt user for connect to devnet fullnode if config does not exist. + // Prompt user for connect to devnet fullnode if config does not exist. if !client_config_path.exists() { let env = match std::env::var_os("ROOCH_CONFIG_WITH_RPC_URL") { Some(v) => Some(Env { @@ -112,8 +112,20 @@ impl CommandAction<()> for Init { .persisted(client_config_path.as_path()) .save()?; } + + let message = format!( + "Rooch config file generated at {}", + client_config_path.display() + ); + + return Ok(message); } - Ok(()) + let message = format!( + "Rooch config file already exists at {}", + client_config_path.display() + ); + + Ok(message) } }