Skip to content
Snippets Groups Projects
Commit 223ec22b authored by Nicolas80's avatar Nicolas80
Browse files

Small cleanup for `vault use` command and saving Config

parent 9c57fb7c
No related branches found
No related tags found
1 merge request!41Adding db persistence for all SecretFormat of vault keys as well as supporting derivations
...@@ -169,13 +169,15 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE ...@@ -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?; 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); 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 => { Subcommand::Generate => {
// TODO allow custom word count // TODO allow custom word count
......
...@@ -96,7 +96,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE ...@@ -96,7 +96,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
} }
} }
Subcommand::Save => { Subcommand::Save => {
save_config(&data); save(&data.cfg);
} }
Subcommand::Default => { Subcommand::Default => {
confy::store(APP_NAME, None, Config::default()).expect("unable to write config"); 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 ...@@ -106,7 +106,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
Ok(()) Ok(())
} }
pub fn save_config(data: &Data) { pub fn save(cfg: &Config) {
confy::store(APP_NAME, None, &data.cfg).expect("unable to write config"); confy::store(APP_NAME, None, cfg).expect("unable to write config");
println!("Configuration updated!"); println!("Configuration updated!");
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment