From 9ef3aa46bd6776fb9cc422df3492b27de5d19df2 Mon Sep 17 00:00:00 2001 From: chaos Date: Thu, 19 Oct 2023 17:48:23 +0100 Subject: [PATCH] allow disabling the genhtml command, error if no extractors are enabled --- Cargo.toml | 16 ++++++++++++---- src/args.rs | 1 + src/commands/mod.rs | 1 + src/main.rs | 1 + src/utils/formats/handlers/mod.rs | 12 ++++++++---- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8040d9d..90f34b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,8 +37,8 @@ metaflac = { version = "0.2", optional = true } taglib = { path = "./modules/taglib", optional = true } # for genhtml command -html-escape = "0.2" -urlencoding = "2" +html-escape = { version = "0.2", optional = true } +urlencoding = { version = "2", optional = true } # error handling thiserror = "1" @@ -51,10 +51,18 @@ tempfile = "3" notify = "6" [features] -default = ["taglib_extractor", "flac_extractor", "mp3_extractor", "ffprobe_extractor"] +default = [ + "mp3_extractor", + "flac_extractor", + "taglib_extractor", + "ffprobe_extractor", + "command_genhtml" +] # Formats taglib_extractor = ["dep:taglib"] flac_extractor = ["dep:metaflac"] mp3_extractor = ["dep:id3"] -ffprobe_extractor = [] # If to allow using ffmpeg/ffprobe as a fallback tag extractor \ No newline at end of file +ffprobe_extractor = [] # If to allow using ffmpeg/ffprobe as a fallback tag extractor + +command_genhtml = ["dep:html-escape", "dep:urlencoding"] \ No newline at end of file diff --git a/src/args.rs b/src/args.rs index 895ae48..87a48da 100644 --- a/src/args.rs +++ b/src/args.rs @@ -12,6 +12,7 @@ pub struct CLIArgs { #[derive(Debug, Clone, Subcommand)] pub enum Commands { Process(commands::process::ProcessCommandArgs), + #[cfg(feature = "command_genhtml")] Genhtml(commands::genhtml::GenHTMLCommandArgs), Transcode(commands::transcode::TranscodeCommandArgs), Copy(commands::copy::CopyCommandArgs), diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 58918a9..f63d373 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -1,4 +1,5 @@ pub mod copy; +#[cfg(feature = "command_genhtml")] pub mod genhtml; pub mod process; pub mod tags; diff --git a/src/main.rs b/src/main.rs index 1929fb5..c62f4a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ fn main() -> Result<(), Box> { Commands::Process(subcommand_args) => { return commands::process::process_command(cli, &subcommand_args); } + #[cfg(feature = "command_genhtml")] Commands::Genhtml(subcommand_args) => { return commands::genhtml::genhtml_command(cli, &subcommand_args); } diff --git a/src/utils/formats/handlers/mod.rs b/src/utils/formats/handlers/mod.rs index de13f94..9264434 100644 --- a/src/utils/formats/handlers/mod.rs +++ b/src/utils/formats/handlers/mod.rs @@ -6,14 +6,18 @@ use lazy_static::lazy_static; use super::{BoxedError, FormatHandler}; -#[cfg(feature = "ffprobe_extractor")] -mod ffprobe; -#[cfg(feature = "flac_extractor")] -mod flac; #[cfg(feature = "mp3_extractor")] mod id3; +#[cfg(feature = "flac_extractor")] +mod flac; #[cfg(feature = "taglib_extractor")] mod taglib; +#[cfg(feature = "ffprobe_extractor")] +mod ffprobe; + + +#[cfg(not(any(feature = "mp3_extractor", feature = "flac_extractor", feature = "taglib_extractor", feature = "ffprobe_extractor")))] +compile_error!("at least one extractor feature must be enabled"); type NewHandlerFuncReturn = Result, BoxedError>; type NewHandlerFunc = fn(path: &PathBuf, file_format: Option) -> NewHandlerFuncReturn;