Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] return a type of string instead of empty to avoid null value #347

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}