Remove old completion generator logic
All checks were successful
Build and test / check (push) Successful in 1m44s
Build and test / build (push) Successful in 3m23s
Build and test / test (push) Successful in 3m6s
Build and test / check-license (push) Successful in 6m8s
Build and test / docs (push) Successful in 5m32s

This commit is contained in:
2025-12-03 13:07:26 +09:00
parent 3ac90dcb26
commit 7bdecf78ff

View File

@@ -2,8 +2,8 @@
extern crate prettytable;
use anyhow::Context;
use clap::{CommandFactory, Parser, ValueEnum, crate_version};
use clap_complete::{CompleteEnv, Shell, generate};
use clap::{CommandFactory, Parser, crate_version};
use clap_complete::CompleteEnv;
use clap_verbosity_flag::{InfoLevel, Verbosity};
use std::path::PathBuf;
@@ -117,29 +117,6 @@ enum Command {
/// Run the server
#[command(hide = true)]
Server(server::command::ServerArgs),
/// Generate shell completions for the program.
#[command(hide = true)]
GenerateCompletions(GenerateCompletionArgs),
}
#[derive(Parser, Debug, Clone)]
struct GenerateCompletionArgs {
/// Which shell to generate completions for.
#[arg(long, default_value = "bash")]
shell: Shell,
/// Which top-level command to generate completions for.
#[arg(long, default_value = "muscl")]
command: ToplevelCommands,
}
#[cfg(feature = "mysql-admutils-compatibility")]
#[derive(ValueEnum, Debug, Clone)]
enum ToplevelCommands {
Muscl,
MysqlDbadm,
MysqlUseradm,
}
/// **WARNING:** This function may be run with elevated privileges.
@@ -159,10 +136,6 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}
if handle_generate_completions_command(&args)?.is_some() {
return Ok(());
}
let connection = bootstrap_server_connection_and_drop_privileges(
args.server_socket_path,
args.config,
@@ -249,37 +222,6 @@ fn handle_server_command(args: &Args) -> anyhow::Result<Option<()>> {
}
}
/// **WARNING:** This function may be run with elevated privileges.
fn handle_generate_completions_command(args: &Args) -> anyhow::Result<Option<()>> {
match args.command {
Command::GenerateCompletions(ref completion_args) => {
assert!(
!executable_is_suid_or_sgid()?,
"The executable should not be SUID or SGID when generating completions"
);
let mut cmd = match completion_args.command {
ToplevelCommands::Muscl => Args::command(),
#[cfg(feature = "mysql-admutils-compatibility")]
ToplevelCommands::MysqlDbadm => mysql_dbadm::Args::command(),
#[cfg(feature = "mysql-admutils-compatibility")]
ToplevelCommands::MysqlUseradm => mysql_useradm::Args::command(),
};
let binary_name = cmd.get_bin_name().unwrap().to_owned();
generate(
completion_args.shell,
&mut cmd,
binary_name,
&mut std::io::stdout(),
);
Ok(Some(()))
}
_ => Ok(None),
}
}
const MIN_TOKIO_WORKER_THREADS: usize = 4;
/// Start a long-lived server using Tokio.
@@ -331,7 +273,6 @@ fn tokio_run_command(command: Command, server_connection: StdUnixStream) -> anyh
client::commands::handle_command(client_args, message_stream).await
}
Command::Server(_) => unreachable!(),
Command::GenerateCompletions(_) => unreachable!(),
}
})
}