From 64e547b40a7f5a0019c9bd90e853d7b1661f7da6 Mon Sep 17 00:00:00 2001 From: Nicolas80 <nicolas.pmail@protonmail.com> Date: Mon, 24 Mar 2025 13:06:30 +0100 Subject: [PATCH] * small fix for `vault use` with Json output format. --- src/commands/vault.rs | 25 ++++++++++++++----------- src/conf.rs | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/commands/vault.rs b/src/commands/vault.rs index 408b830..16118a3 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 1577fad..3850c9f 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!"); } -- GitLab