message: cleanup build.rs file
diff: use clap::IntoApp;
  use clap_complete::{
  - generate_to,
  shells::{Bash, Elvish, Fish, PowerShell, Zsh},
  + Generator,
  };
  use std::io::Error;
  use std::{env, path::PathBuf};
  @@ -16,23 +16,34 @@ fn main() -> Result<(), Error> {
  Some(out_dir) => out_dir,
  };
  - let mut app = Cli::command();
  + let app = Cli::command();
  let bin_name = app.get_name().to_string();
  - // This is an attempt at being smart. Instead, one could just generate completion scripts for all of the shells in a completions/ directory and have the user choose the appropriate one.
  - let path = match env::var("SHELL") {
  - Ok(s) if s.contains("bash") => generate_to(Bash, &mut app, bin_name, out_dir)?,
  - Ok(s) if s.contains("fish") => generate_to(Fish, &mut app, bin_name, out_dir)?,
  - Ok(s) if s.contains("zsh") => generate_to(Zsh, &mut app, bin_name, out_dir)?,
  - Ok(s) if s.contains("elvish") => generate_to(Elvish, &mut app, bin_name, out_dir)?,
  - Ok(s) if s.contains("powershell") => generate_to(PowerShell, &mut app, bin_name, out_dir)?,
  + let shell: Box<dyn Generator> = match env::var("SHELL") {
  + Ok(s) if s.contains("bash") => Box::new(Bash),
  + Ok(s) if s.contains("fish") => Box::new(Fish),
  + Ok(s) if s.contains("zsh") => Box::new(Zsh),
  + Ok(s) if s.contains("elvish") => Box::new(Elvish),
  + Ok(s) if s.contains("powershell") => Box::new(PowerShell),
  Ok(_) | Err(_) => {
  - let mut x = PathBuf::new();
  - x.push("Your shell could not be detected from the $SHELL environment variable so no shell completions were generated. Check the build.rs file if you want to see how this was generated.");
  - x
  + println!(
  + "cargo:warning=Your shell could not be detected from the $SHELL environment variable so no shell completions were generated. Check the build.rs file if you want to see how this was generated.",
  + );
  + println!("cargo:warning=Raise an issue if this doesn't work for you",);
  + return Ok(());
  }
  };
  + let mut path = PathBuf::from(out_dir);
  + path.set_file_name(shell.file_name(&bin_name));
  + // Check if tab completions file already exists and return if so
  + if path.is_file() {
  + return Ok(());
  + }
  +
  + // This is an attempt at being smart. Instead, one could just generate completion scripts for all of the shells in a completions/ directory and have the user choose the appropriate one.
  + shell.generate(&app, &mut std::fs::File::create(path.clone())?);
  +
  println!(
  "cargo:warning={} completion file is generated: {path:?}",
  app.get_name()
  