Skip to content

Commit

Permalink
[cli] return a string for init command. (#347)
Browse files Browse the repository at this point in the history
Co-authored-by: Feliciss <10203-feliciss@users.noreply.0xacab.org>
  • Loading branch information
feliciss and Feliciss committed Jun 26, 2023
1 parent 0483b79 commit e20712c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions crates/rooch/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub struct Init {
}

#[async_trait]
impl CommandAction<()> for Init {
async fn execute(self) -> RoochResult<()> {
impl CommandAction<String> for Init {
async fn execute(self) -> RoochResult<String> {
let client_config_path = match self.context_options.config_dir {
Some(v) => {
if !v.exists() {
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit e20712c

Please sign in to comment.