diff --git a/src/commands/vault.rs b/src/commands/vault.rs index a817acbca92c95100a1d38fc39d43b2ae6f93afe..43432d52b7715baba65fff285c119b4ae9215f45 100644 --- a/src/commands/vault.rs +++ b/src/commands/vault.rs @@ -325,14 +325,25 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE } => { let account = retrieve_vault_account(db, address_or_vault_name).await?; + if OutputFormat::Human == data.args.output_format { + println!("Using: {}", account); + } + + let updated_cfg = conf::Config { + address: Some(account.address.0.clone()), + ..data.cfg + }; + + //This updated configuration will be picked up with next GCli execution + conf::save(&updated_cfg); + match data.args.output_format { OutputFormat::Human => { - println!("Using: {}", account); + println!("Configuration updated!"); } OutputFormat::Json => { let json_view = serde_json::json!({ - //FIXME Probably not the display we would expect - "address": account.to_string() + "address": account.address.to_string() }); println!( "{}", @@ -340,14 +351,6 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE ); } } - - let updated_cfg = conf::Config { - address: Some(account.address.0), - ..data.cfg - }; - - //This updated configuration will be picked up with next GCli execution - conf::save(&updated_cfg); } Subcommand::Generate => { // TODO allow custom word count diff --git a/src/conf.rs b/src/conf.rs index 1577faddf9720c5b6379395220f0562197dca88a..3850c9fd3583a244230cb601c111375d537813fd 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -132,6 +132,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE }, Subcommand::Save => { save(&data.cfg); + println!("Configuration updated!"); } Subcommand::Default => { confy::store(APP_NAME, None, Config::default()).expect("unable to write config"); @@ -143,5 +144,4 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE pub fn save(cfg: &Config) { confy::store(APP_NAME, None, cfg).expect("unable to write config"); - println!("Configuration updated!"); }