Add dynamic completion for users and databases
All checks were successful
All checks were successful
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_database_completer,
|
||||
protocol::{
|
||||
ClientToServerMessageStream, Request, Response, print_drop_databases_output_status,
|
||||
print_drop_databases_output_status_json,
|
||||
@@ -16,7 +18,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct DropDbArgs {
|
||||
/// The MySQL database(s) to drop
|
||||
#[arg(num_args = 1..)]
|
||||
#[arg(num_args = 1.., add = ArgValueCompleter::new(mysql_database_completer))]
|
||||
name: Vec<MySQLDatabase>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_user_completer,
|
||||
protocol::{
|
||||
ClientToServerMessageStream, Request, Response, print_drop_users_output_status,
|
||||
print_drop_users_output_status_json,
|
||||
@@ -16,7 +18,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct DropUserArgs {
|
||||
/// The MySQL user(s) to drop
|
||||
#[arg(num_args = 1..)]
|
||||
#[arg(num_args = 1.., add = ArgValueCompleter::new(mysql_user_completer))]
|
||||
username: Vec<MySQLUser>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::collections::BTreeSet;
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use dialoguer::{Confirm, Editor};
|
||||
use futures_util::SinkExt;
|
||||
use nix::unistd::{User, getuid};
|
||||
@@ -10,6 +11,7 @@ use tokio_stream::StreamExt;
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_database_completer,
|
||||
database_privileges::{
|
||||
DatabasePrivilegeEditEntry, DatabasePrivilegeRow, DatabasePrivilegeRowDiff,
|
||||
DatabasePrivilegesDiff, create_or_modify_privilege_rows, diff_privileges,
|
||||
@@ -27,6 +29,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct EditPrivsArgs {
|
||||
/// The MySQL database to edit privileges for
|
||||
#[arg(add = ArgValueCompleter::new(mysql_database_completer))]
|
||||
pub name: Option<MySQLDatabase>,
|
||||
|
||||
#[arg(
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_user_completer,
|
||||
protocol::{
|
||||
ClientToServerMessageStream, Request, Response, print_lock_users_output_status,
|
||||
print_lock_users_output_status_json,
|
||||
@@ -16,7 +18,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct LockUserArgs {
|
||||
/// The MySQL user(s) to lock
|
||||
#[arg(num_args = 1..)]
|
||||
#[arg(num_args = 1.., add = ArgValueCompleter::new(mysql_user_completer))]
|
||||
username: Vec<MySQLUser>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::path::PathBuf;
|
||||
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use dialoguer::Password;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
@@ -9,6 +10,7 @@ use tokio_stream::StreamExt;
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_user_completer,
|
||||
protocol::{
|
||||
ClientToServerMessageStream, ListUsersError, Request, Response,
|
||||
print_set_password_output_status,
|
||||
@@ -20,6 +22,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct PasswdUserArgs {
|
||||
/// The MySQL user whose password is to be changed
|
||||
#[arg(add = ArgValueCompleter::new(mysql_user_completer))]
|
||||
username: MySQLUser,
|
||||
|
||||
/// Read the new password from a file instead of prompting for it
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use prettytable::{Cell, Row, Table};
|
||||
use tokio_stream::StreamExt;
|
||||
@@ -6,6 +7,7 @@ use tokio_stream::StreamExt;
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_database_completer,
|
||||
protocol::{ClientToServerMessageStream, Request, Response},
|
||||
types::MySQLDatabase,
|
||||
},
|
||||
@@ -14,7 +16,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct ShowDbArgs {
|
||||
/// The MySQL database(s) to show
|
||||
#[arg(num_args = 0..)]
|
||||
#[arg(num_args = 0.., add = ArgValueCompleter::new(mysql_database_completer))]
|
||||
name: Vec<MySQLDatabase>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use prettytable::{Cell, Row, Table};
|
||||
use tokio_stream::StreamExt;
|
||||
@@ -7,6 +8,7 @@ use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
common::yn,
|
||||
completion::mysql_database_completer,
|
||||
database_privileges::{DATABASE_PRIVILEGE_FIELDS, db_priv_field_human_readable_name},
|
||||
protocol::{ClientToServerMessageStream, Request, Response},
|
||||
types::MySQLDatabase,
|
||||
@@ -16,7 +18,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct ShowPrivsArgs {
|
||||
/// The MySQL database(s) to show privileges for
|
||||
#[arg(num_args = 0..)]
|
||||
#[arg(num_args = 0.., add = ArgValueCompleter::new(mysql_database_completer))]
|
||||
name: Vec<MySQLDatabase>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
use anyhow::Context;
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_user_completer,
|
||||
protocol::{ClientToServerMessageStream, Request, Response},
|
||||
types::MySQLUser,
|
||||
},
|
||||
@@ -14,7 +16,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct ShowUserArgs {
|
||||
/// The MySQL user(s) to show
|
||||
#[arg(num_args = 0..)]
|
||||
#[arg(num_args = 0.., add = ArgValueCompleter::new(mysql_user_completer))]
|
||||
username: Vec<MySQLUser>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
use clap::Parser;
|
||||
use clap_complete::ArgValueCompleter;
|
||||
use futures_util::SinkExt;
|
||||
use tokio_stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
client::commands::erroneous_server_response,
|
||||
core::{
|
||||
completion::mysql_user_completer,
|
||||
protocol::{
|
||||
ClientToServerMessageStream, Request, Response, print_unlock_users_output_status,
|
||||
print_unlock_users_output_status_json,
|
||||
@@ -16,7 +18,7 @@ use crate::{
|
||||
#[derive(Parser, Debug, Clone)]
|
||||
pub struct UnlockUserArgs {
|
||||
/// The MySQL user(s) to unlock
|
||||
#[arg(num_args = 1..)]
|
||||
#[arg(num_args = 1.., add = ArgValueCompleter::new(mysql_user_completer))]
|
||||
username: Vec<MySQLUser>,
|
||||
|
||||
/// Print the information as JSON
|
||||
|
||||
Reference in New Issue
Block a user