diff --git a/src/client/commands.rs b/src/client/commands.rs index 875a865..f4de82c 100644 --- a/src/client/commands.rs +++ b/src/client/commands.rs @@ -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`: /// - /// `muscle edit-db-privs -p my_db:my_user:siu` + /// `muscle edit-privs -p my_db:my_user:siu` /// /// Enable all privileges for user `my_other_user` on database `my_other_db`: /// - /// `muscle edit-db-privs -p my_other_db:my_other_user:A` + /// `muscle edit-privs -p my_other_db:my_other_user:A` /// /// Set miscellaneous privileges for multiple users on database `my_db`: /// - /// `muscle edit-db-privs my_db -p my_user:siu my_other_user:ct`` + /// `muscle 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, diff --git a/src/client/commands/edit_db_privs.rs b/src/client/commands/edit_privs.rs similarity index 98% rename from src/client/commands/edit_db_privs.rs rename to src/client/commands/edit_privs.rs index 3864c07..1245960 100644 --- a/src/client/commands/edit_db_privs.rs +++ b/src/client/commands/edit_privs.rs @@ -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, @@ -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> { debug_assert!(!args.privs.is_empty()); args.privs diff --git a/src/client/commands/show_db_privs.rs b/src/client/commands/show_privs.rs similarity index 98% rename from src/client/commands/show_db_privs.rs rename to src/client/commands/show_privs.rs index ad90691..6450687 100644 --- a/src/client/commands/show_db_privs.rs +++ b/src/client/commands/show_privs.rs @@ -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, @@ -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() { diff --git a/src/client/mysql_admutils_compatibility/mysql_dbadm.rs b/src/client/mysql_admutils_compatibility/mysql_dbadm.rs index 4c6d0a7..aa90d77 100644 --- a/src/client/mysql_admutils_compatibility/mysql_dbadm.rs +++ b/src/client/mysql_admutils_compatibility/mysql_dbadm.rs @@ -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,