client: rename <verb>-db-privs -> <verb>-privs
This commit is contained in:
@@ -2,11 +2,11 @@ mod create_db;
|
||||
mod create_user;
|
||||
mod drop_db;
|
||||
mod drop_user;
|
||||
mod edit_db_privs;
|
||||
mod edit_privs;
|
||||
mod lock_user;
|
||||
mod passwd_user;
|
||||
mod show_db;
|
||||
mod show_db_privs;
|
||||
mod show_privs;
|
||||
mod show_user;
|
||||
mod unlock_user;
|
||||
|
||||
@@ -14,11 +14,11 @@ pub use create_db::*;
|
||||
pub use create_user::*;
|
||||
pub use drop_db::*;
|
||||
pub use drop_user::*;
|
||||
pub use edit_db_privs::*;
|
||||
pub use edit_privs::*;
|
||||
pub use lock_user::*;
|
||||
pub use passwd_user::*;
|
||||
pub use show_db::*;
|
||||
pub use show_db_privs::*;
|
||||
pub use show_privs::*;
|
||||
pub use show_user::*;
|
||||
pub use unlock_user::*;
|
||||
|
||||
@@ -46,9 +46,9 @@ pub enum ClientCommand {
|
||||
///
|
||||
/// If no database names are provided, all databases you have access to will be shown.
|
||||
#[command()]
|
||||
ShowDbPrivs(ShowDbPrivsArgs),
|
||||
ShowPrivs(ShowPrivsArgs),
|
||||
|
||||
/// Change user privileges for one or more databases. See `edit-db-privs --help` for details.
|
||||
/// Change user privileges for one or more databases. See `edit-privs --help` for details.
|
||||
///
|
||||
/// This command has two modes of operation:
|
||||
///
|
||||
@@ -80,7 +80,7 @@ pub enum ClientCommand {
|
||||
/// - `A` - ALL PRIVILEGES
|
||||
///
|
||||
/// If you provide a database name, you can omit it from the privilege string,
|
||||
/// e.g. `edit-db-privs my_db -p my_user+siu` is equivalent to `edit-db-privs -p my_db:my_user:siu`.
|
||||
/// e.g. `edit-privs my_db -p my_user+siu` is equivalent to `edit-privs -p my_db:my_user:siu`.
|
||||
/// While it doesn't make much of a difference for a single edit, it can be useful for editing multiple users
|
||||
/// on the same database at once.
|
||||
///
|
||||
@@ -88,18 +88,18 @@ pub enum ClientCommand {
|
||||
///
|
||||
/// Enable privileges `SELECT`, `INSERT`, and `UPDATE` for user `my_user` on database `my_db`:
|
||||
///
|
||||
/// `muscl edit-db-privs -p my_db:my_user:siu`
|
||||
/// `muscl edit-privs -p my_db:my_user:siu`
|
||||
///
|
||||
/// Enable all privileges for user `my_other_user` on database `my_other_db`:
|
||||
///
|
||||
/// `muscl edit-db-privs -p my_other_db:my_other_user:A`
|
||||
/// `muscl edit-privs -p my_other_db:my_other_user:A`
|
||||
///
|
||||
/// Set miscellaneous privileges for multiple users on database `my_db`:
|
||||
///
|
||||
/// `muscl edit-db-privs my_db -p my_user:siu my_other_user:ct``
|
||||
/// `muscl edit-privs my_db -p my_user:siu my_other_user:ct``
|
||||
///
|
||||
#[command(verbatim_doc_comment)]
|
||||
EditDbPrivs(EditDbPrivsArgs),
|
||||
EditPrivs(EditPrivsArgs),
|
||||
|
||||
/// Create one or more users
|
||||
#[command()]
|
||||
@@ -136,8 +136,8 @@ pub async fn handle_command(
|
||||
ClientCommand::CreateDb(args) => create_databases(args, server_connection).await,
|
||||
ClientCommand::DropDb(args) => drop_databases(args, server_connection).await,
|
||||
ClientCommand::ShowDb(args) => show_databases(args, server_connection).await,
|
||||
ClientCommand::ShowDbPrivs(args) => show_database_privileges(args, server_connection).await,
|
||||
ClientCommand::EditDbPrivs(args) => edit_database_privileges(args, server_connection).await,
|
||||
ClientCommand::ShowPrivs(args) => show_database_privileges(args, server_connection).await,
|
||||
ClientCommand::EditPrivs(args) => edit_database_privileges(args, server_connection).await,
|
||||
ClientCommand::CreateUser(args) => create_users(args, server_connection).await,
|
||||
ClientCommand::DropUser(args) => drop_users(args, server_connection).await,
|
||||
ClientCommand::PasswdUser(args) => passwd_user(args, server_connection).await,
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct EditDbPrivsArgs {
|
||||
pub struct EditPrivsArgs {
|
||||
/// The name of the database to edit privileges for
|
||||
pub name: Option<MySQLDatabase>,
|
||||
|
||||
@@ -52,7 +52,7 @@ pub struct EditDbPrivsArgs {
|
||||
}
|
||||
|
||||
pub async fn edit_database_privileges(
|
||||
args: EditDbPrivsArgs,
|
||||
args: EditPrivsArgs,
|
||||
mut server_connection: ClientToServerMessageStream,
|
||||
) -> anyhow::Result<()> {
|
||||
let message = Request::ListPrivileges(args.name.to_owned().map(|name| vec![name]));
|
||||
@@ -130,7 +130,7 @@ pub async fn edit_database_privileges(
|
||||
}
|
||||
|
||||
fn parse_privilege_tables_from_args(
|
||||
args: &EditDbPrivsArgs,
|
||||
args: &EditPrivsArgs,
|
||||
) -> anyhow::Result<BTreeSet<DatabasePrivilegeRowDiff>> {
|
||||
debug_assert!(!args.privs.is_empty());
|
||||
args.privs
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
};
|
||||
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct ShowDbPrivsArgs {
|
||||
pub struct ShowPrivsArgs {
|
||||
/// The name of the database(s) to show
|
||||
#[arg(num_args = 0..)]
|
||||
name: Vec<MySQLDatabase>,
|
||||
@@ -25,7 +25,7 @@ pub struct ShowDbPrivsArgs {
|
||||
}
|
||||
|
||||
pub async fn show_database_privileges(
|
||||
args: ShowDbPrivsArgs,
|
||||
args: ShowPrivsArgs,
|
||||
mut server_connection: ClientToServerMessageStream,
|
||||
) -> anyhow::Result<()> {
|
||||
let message = if args.name.is_empty() {
|
||||
@@ -6,7 +6,7 @@ use tokio::net::UnixStream as TokioUnixStream;
|
||||
|
||||
use crate::{
|
||||
client::{
|
||||
commands::{EditDbPrivsArgs, edit_database_privileges, erroneous_server_response},
|
||||
commands::{EditPrivsArgs, edit_database_privileges, erroneous_server_response},
|
||||
mysql_admutils_compatibility::{
|
||||
common::trim_db_name_to_32_chars,
|
||||
error_messages::{
|
||||
@@ -187,7 +187,7 @@ fn tokio_run_command(command: Command, server_connection: StdUnixStream) -> anyh
|
||||
Command::Drop(args) => drop_databases(args, message_stream).await,
|
||||
Command::Show(args) => show_databases(args, message_stream).await,
|
||||
Command::Editperm(args) => {
|
||||
let edit_privileges_args = EditDbPrivsArgs {
|
||||
let edit_privileges_args = EditPrivsArgs {
|
||||
name: Some(args.database),
|
||||
privs: vec![],
|
||||
json: false,
|
||||
|
||||
Reference in New Issue
Block a user