Reimplement most of the tool:
Most of the tool has been reimplemented, with the exception of the permission editing feature, which is currently half implemented. There are also several TODOs spread around that would benefit from some action
This commit is contained in:
77
src/main.rs
77
src/main.rs
@@ -1,61 +1,48 @@
|
||||
#[macro_use]
|
||||
extern crate prettytable;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
mod database_command;
|
||||
mod user_command;
|
||||
mod cli;
|
||||
mod core;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
#[clap(subcommand)]
|
||||
#[command(subcommand)]
|
||||
command: Command,
|
||||
|
||||
#[command(flatten)]
|
||||
config_overrides: core::config::ConfigOverrideArgs,
|
||||
}
|
||||
|
||||
/// Database administration tool designed for non-admin users to manage their own MySQL databases and users.
|
||||
/// Use `--help` for advanced usage.
|
||||
///
|
||||
/// This tool allows you to manage users and databases in MySQL that are prefixed with your username.
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, disable_help_subcommand = true)]
|
||||
enum Command {
|
||||
/// Create, drop or edit permission for the DATABASE(s),
|
||||
#[clap(name = "db")]
|
||||
Database(database_command::DatabaseArgs),
|
||||
/// Create, drop or show/edit permissions for DATABASE(s),
|
||||
#[command(alias = "database")]
|
||||
Db(cli::database_command::DatabaseArgs),
|
||||
|
||||
/// Create, delete or change password for your USER,
|
||||
#[clap(name = "user")]
|
||||
User(user_command::UserArgs),
|
||||
// Database(cli::database_command::DatabaseArgs),
|
||||
/// Create, drop, change password for, or show your USER(s),
|
||||
#[command(name = "user")]
|
||||
User(cli::user_command::UserArgs),
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
env_logger::init();
|
||||
let args: Args = Args::parse();
|
||||
let config = core::config::get_config(args.config_overrides)?;
|
||||
let connection = core::config::mysql_connection_from_config(config).await?;
|
||||
|
||||
match args.command {
|
||||
Command::Database(database_args) => database_command::handle_command(database_args),
|
||||
Command::User(user_args) => user_command::handle_command(user_args),
|
||||
Command::Db(database_args) => {
|
||||
cli::database_command::handle_command(database_args, connection).await
|
||||
}
|
||||
Command::User(user_args) => cli::user_command::handle_command(user_args, connection).await,
|
||||
}
|
||||
}
|
||||
|
||||
// loginstud03% mysql-dbadm --help
|
||||
|
||||
// Usage: mysql-dbadm COMMAND [DATABASE]...
|
||||
// Create, drop og edit permission for the DATABASE(s),
|
||||
// as determined by the COMMAND. Valid COMMANDs:
|
||||
|
||||
// create create the DATABASE(s).
|
||||
// drop delete the DATABASE(s).
|
||||
// show give information about the DATABASE(s), or, if
|
||||
// none are given, all the ones you own.
|
||||
// editperm change permissions for the DATABASE(s). Your
|
||||
// favorite editor will be started, allowing you
|
||||
// to make changes to the permission table.
|
||||
// Run 'mysql-dbadm --help-editperm' for more
|
||||
// information.
|
||||
|
||||
// Report bugs to orakel@ntnu.no
|
||||
|
||||
// loginstud03% mysql-useradm --help
|
||||
|
||||
// Usage: mysql-useradm COMMAND [USER]...
|
||||
// Create, delete or change password for the USER(s),
|
||||
// as determined by the COMMAND. Valid COMMANDs:
|
||||
|
||||
// create create the USER(s).
|
||||
// delete delete the USER(s).
|
||||
// passwd change the MySQL password for the USER(s).
|
||||
// show give information about the USERS(s), or, if
|
||||
// none are given, all the users you have.
|
||||
|
||||
// Report bugs to orakel@ntnu.no
|
||||
}
|
||||
Reference in New Issue
Block a user