@@ -61,8 +61,7 @@ fn main() {
6161 ( "migration" , Some ( matches) ) => run_migration_command ( matches) . unwrap_or_else ( handle_error) ,
6262 ( "setup" , Some ( matches) ) => run_setup_command ( matches) ,
6363 ( "database" , Some ( matches) ) => run_database_command ( matches) . unwrap_or_else ( handle_error) ,
64- ( "bash-completion" , Some ( matches) ) => generate_bash_completion_command ( matches) ,
65- ( "zsh-completion" , Some ( matches) ) => generate_zsh_completion_command ( matches) ,
64+ ( "completions" , Some ( matches) ) => generate_completions_command ( matches) ,
6665 ( "print-schema" , Some ( matches) ) => run_infer_schema ( matches) . unwrap_or_else ( handle_error) ,
6766 _ => unreachable ! ( "The cli parser should prevent reaching here" ) ,
6867 }
@@ -245,12 +244,14 @@ fn run_database_command(matches: &ArgMatches) -> Result<(), Box<Error>> {
245244 Ok ( ( ) )
246245}
247246
248- fn generate_bash_completion_command ( _: & ArgMatches ) {
249- cli:: build_cli ( ) . gen_completions_to ( "diesel" , Shell :: Bash , & mut stdout ( ) ) ;
250- }
251-
252- fn generate_zsh_completion_command ( _: & ArgMatches ) {
253- cli:: build_cli ( ) . gen_completions_to ( "diesel" , Shell :: Zsh , & mut stdout ( ) ) ;
247+ fn generate_completions_command ( matches : & ArgMatches ) {
248+ let shell = match matches. subcommand ( ) {
249+ ( "bash" , _) => Shell :: Bash ,
250+ ( "fish" , _) => Shell :: Fish ,
251+ ( "zsh" , _) => Shell :: Zsh ,
252+ _ => unreachable ! ( "The cli parser should prevent reaching here" ) ,
253+ } ;
254+ cli:: build_cli ( ) . gen_completions_to ( "diesel" , shell, & mut stdout ( ) ) ;
254255}
255256
256257/// Looks for a migrations directory in the current path and all parent paths,
0 commit comments