tagdex 1.0.0

An mp3 tag indexer written in Rust.
Documentation
use clap::{Arg, ArgAction, Command};
use clap_complete::{
  aot::{Bash, Fish, Zsh},
  generate,
};

pub fn command() -> Command {
  Command::new("tagdex")
    .disable_help_flag(true)
    .subcommand_required(true)
    .arg(
      Arg::new("path")
        .long("path")
        .value_parser(clap::builder::PathBufValueParser::new())
        .help("The path of the music directory."),
    )
    .subcommand(Command::new("index").about("Index a music directory."))
    .subcommands(
      [
        Command::new("title").about("Filter by title."),
        Command::new("album").about("Filter by album."),
        Command::new("artist").about("Filter by artist."),
        Command::new("genre").about("Filter by genre."),
        Command::new("year").about("Filter by year."),
      ]
      .map(|cmd| {
        cmd.arg(
          Arg::new("null")
            .long("null")
            .action(ArgAction::SetTrue)
            .help("Separate output with null characters."),
        )
      }),
    )
    .subcommand(
      Command::new("complete")
        .arg(
          Arg::new("shell").value_parser(clap::builder::PossibleValuesParser::new([
            "bash", "fish", "zsh",
          ])),
        )
        .about("Print out shell completions."),
    )
}

pub fn complete(shell: &String) {
  match shell.as_str() {
    "bash" => generate(Bash, &mut command(), "tagdex", &mut std::io::stdout()),
    "fish" => generate(Zsh, &mut command(), "tagdex", &mut std::io::stdout()),
    "zsh" => generate(Fish, &mut command(), "tagdex", &mut std::io::stdout()),
    _ => (),
  }
}