move get-tags/set-tags into "musicutil tags {get,set}" subcommands

This commit is contained in:
chaos 2023-10-19 17:39:28 +01:00
parent d537eb328f
commit 3dcd04a9fb
No known key found for this signature in database
6 changed files with 36 additions and 25 deletions

View file

@ -15,6 +15,5 @@ pub enum Commands {
Genhtml(commands::genhtml::GenHTMLCommandArgs), Genhtml(commands::genhtml::GenHTMLCommandArgs),
Transcode(commands::transcode::TranscodeCommandArgs), Transcode(commands::transcode::TranscodeCommandArgs),
Copy(commands::copy::CopyCommandArgs), Copy(commands::copy::CopyCommandArgs),
SetTags(commands::set_tags::SetTagsCommandArgs), Tags(commands::tags::TagsArgs),
GetTags(commands::get_tags::GetTagsCommandArgs),
} }

View file

@ -1,6 +1,5 @@
pub mod copy; pub mod copy;
pub mod genhtml; pub mod genhtml;
pub mod get_tags;
pub mod process; pub mod process;
pub mod set_tags; pub mod tags;
pub mod transcode; pub mod transcode;

View file

@ -14,7 +14,6 @@ pub struct GetTagsCommandArgs {
pub json: bool, pub json: bool,
} }
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
struct Tags { struct Tags {
title: String, title: String,

24
src/commands/tags/mod.rs Normal file
View file

@ -0,0 +1,24 @@
use crate::args::CLIArgs;
mod get;
mod set;
#[derive(Debug, Clone, clap::Args)]
pub struct TagsArgs {
#[clap(subcommand)]
pub command: TagsCommands,
}
#[derive(Debug, Clone, clap::Subcommand)]
pub enum TagsCommands {
Get(get::GetTagsCommandArgs),
Set(set::SetTagsCommandArgs),
}
pub fn tags_command(args: CLIArgs, tags_args: &TagsArgs) -> Result<(), Box<dyn std::error::Error>> {
let command = tags_args.command.to_owned();
match command {
TagsCommands::Get(subcommand_args) => return get::get_tags_command(args, &subcommand_args),
TagsCommands::Set(subcommand_args) => return set::set_tags_command(args, &subcommand_args),
}
}

View file

@ -7,36 +7,26 @@ pub mod utils;
use args::{CLIArgs, Commands}; use args::{CLIArgs, Commands};
use clap::Parser; use clap::Parser;
use commands::copy::copy_command;
use commands::genhtml::genhtml_command;
use commands::get_tags::get_tags_command;
use commands::process::process_command;
use commands::set_tags::set_tags_command;
use commands::transcode::transcode_command;
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = CLIArgs::parse(); let cli = CLIArgs::parse();
let command = cli.command.to_owned(); let command = cli.command.to_owned();
match command { match command {
Commands::Process(process_args) => { Commands::Process(subcommand_args) => {
return process_command(cli, &process_args); return commands::process::process_command(cli, &subcommand_args);
} }
Commands::Genhtml(genhtml_args) => { Commands::Genhtml(subcommand_args) => {
return genhtml_command(cli, &genhtml_args); return commands::genhtml::genhtml_command(cli, &subcommand_args);
} }
Commands::Transcode(transcode_args) => { Commands::Transcode(subcommand_args) => {
return transcode_command(cli, &transcode_args); return commands::transcode::transcode_command(cli, &subcommand_args);
} }
Commands::Copy(copy_args) => { Commands::Copy(subcommand_args) => {
return copy_command(cli, &copy_args); return commands::copy::copy_command(cli, &subcommand_args);
} }
Commands::SetTags(set_tags_args) => { Commands::Tags(subcommand_args) => {
return set_tags_command(cli, &set_tags_args); return commands::tags::tags_command(cli, &subcommand_args);
}
Commands::GetTags(get_tags_args) => {
return get_tags_command(cli, &get_tags_args);
} }
} }
} }