edit-db-privs: display diffs and ask before commiting

This commit is contained in:
2024-08-08 21:48:17 +02:00
parent 7ee60dacdc
commit e420c1f4d5
2 changed files with 262 additions and 156 deletions

View File

@@ -1,6 +1,6 @@
use anyhow::Context;
use clap::Parser;
use dialoguer::Editor;
use dialoguer::{Confirm, Editor};
use prettytable::{Cell, Row, Table};
use sqlx::{Connection, MySqlConnection};
@@ -330,7 +330,17 @@ pub async fn edit_privileges(
return Ok(CommandStatus::NoModificationsNeeded);
}
// TODO: Add confirmation prompt.
println!("The following changes will be made:\n");
println!("{}", display_privilege_diffs(&diffs));
if !args.yes
&& !Confirm::new()
.with_prompt("Do you want to apply these changes?")
.default(false)
.show_default(true)
.interact()?
{
return Ok(CommandStatus::Cancelled);
}
apply_privilege_diffs(diffs, connection).await?;