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

* small fix for `vault use` with Json output format.

parent f72566bd
No related branches found
No related tags found
1 merge request!46Json output
Pipeline #40188 passed
......@@ -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
......
......@@ -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!");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment