diff --git a/src/commands/vault.rs b/src/commands/vault.rs index adf9245665340255d12be67721f07ee9ca4b9d04..8c8fc31dd69be7fb818815bbfef15308ea12151b 100644 --- a/src/commands/vault.rs +++ b/src/commands/vault.rs @@ -169,13 +169,15 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE } => { let derivation = retrieve_vault_derivation(&data, address_or_vault_name).await?; - //FIXME not sure if this is ok (but since it's a CLI; this data instance won't be used afterwards) - let mut data = data; - data.cfg.address = - Some(AccountId::from_str(&derivation.address).expect("invalid address")); - println!("Using: {}", derivation); - conf::save_config(&data); + + let updated_cfg = conf::Config { + address: Some(AccountId::from_str(&derivation.address).expect("invalid address")), + ..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 95f527907bc9f9015aa17d848476b72a10bc1526..207e7c68b7ac8998e3c3240224eae52b01312b97 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -96,7 +96,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE } } Subcommand::Save => { - save_config(&data); + save(&data.cfg); } Subcommand::Default => { confy::store(APP_NAME, None, Config::default()).expect("unable to write config"); @@ -106,7 +106,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE Ok(()) } -pub fn save_config(data: &Data) { - confy::store(APP_NAME, None, &data.cfg).expect("unable to write config"); +pub fn save(cfg: &Config) { + confy::store(APP_NAME, None, cfg).expect("unable to write config"); println!("Configuration updated!"); }