diff --git a/src/clipper.rs b/src/clipper.rs index eac7b48..131e337 100644 --- a/src/clipper.rs +++ b/src/clipper.rs @@ -42,7 +42,7 @@ impl Clipper { "no-video" | "vn" => inputs.set_no_video(true), "no-audio" | "an" => inputs.set_no_audio(true), "dry-run" | "d" => dry_run = true, - _ => error!(format!("Invalid option: -{option}")), + _ => error!("Invalid option: -{option}"), } continue; @@ -140,8 +140,8 @@ macro_rules! string_vec { #[macro_export] macro_rules! error { - ($message:expr) => {{ - println!("\x1b[38;5;203m{}\x1b[0m", $message); + ($string:expr) => {{ + println!("\x1b[38;5;203m{}\x1b[0m", format!($string)); std::process::exit(1); }}; } diff --git a/src/ffmpeg/encoder.rs b/src/ffmpeg/encoder.rs index 5392f0d..80587eb 100644 --- a/src/ffmpeg/encoder.rs +++ b/src/ffmpeg/encoder.rs @@ -29,7 +29,7 @@ impl Encoder { } self.crf = Some(crf.parse::().unwrap_or_else(|_| { - error!(format!("Invalid CRF value: {crf}")); + error!("Invalid CRF value: {crf}"); })); } @@ -39,7 +39,7 @@ impl Encoder { } self.cq = Some(cq.parse::().unwrap_or_else(|_| { - error!(format!("Invalid CQ value: {cq}")); + error!("Invalid CQ value: {cq}"); })); } } diff --git a/src/ffmpeg/input.rs b/src/ffmpeg/input.rs index 8c1eeba..e3e0bd0 100644 --- a/src/ffmpeg/input.rs +++ b/src/ffmpeg/input.rs @@ -25,19 +25,19 @@ impl Input { pub fn set_video_track(&mut self, video_track: String) { self.video_track = video_track.parse::().unwrap_or_else(|_| { - error!(format!("Invalid video track: {video_track}")); + error!("Invalid video track: {video_track}"); }); } pub fn set_audio_track(&mut self, audio_track: String) { self.audio_track = audio_track.parse::().unwrap_or_else(|_| { - error!(format!("Invalid audio track: {audio_track}")); + error!("Invalid audio track: {audio_track}"); }); } pub fn set_subtitle_track(&mut self, subtitle_track: String) { self.subtitle_track = Some(subtitle_track.parse::().unwrap_or_else(|_| { - error!(format!("Invalid subtitle track: {subtitle_track}")); + error!("Invalid subtitle track: {subtitle_track}"); })); } } diff --git a/src/ffmpeg/inputs.rs b/src/ffmpeg/inputs.rs index 6fca3f9..ea01970 100644 --- a/src/ffmpeg/inputs.rs +++ b/src/ffmpeg/inputs.rs @@ -48,7 +48,8 @@ impl IntoIterator for Inputs { } if let Some(input) = self.inputs.iter().find(|input| input.segments.is_empty()) { - error!(format!(r#"Input "{}" has no segments."#, input.file)); + let file = &input.file; + error!(r#"Input "{file}" has no segments."#); } if self.no_video && self.no_audio { @@ -80,7 +81,7 @@ impl IntoIterator for Inputs { .split_once('-') .map(|(from, to)| (duration_to_secs(from), duration_to_secs(to))) .unwrap_or_else(|| { - error!(format!("Invalid segment duration range: {segment}")); + error!("Invalid segment duration range: {segment}"); }); let fade_to = to - self.fade.unwrap_or(0.) - 0.5; diff --git a/src/ffmpeg/mod.rs b/src/ffmpeg/mod.rs index 01495e8..5a1b9ff 100644 --- a/src/ffmpeg/mod.rs +++ b/src/ffmpeg/mod.rs @@ -17,7 +17,7 @@ pub fn duration_to_secs(duration: T) -> f64 { .map(|entry| { entry .parse::() - .unwrap_or_else(|_| error!(format!("Invalid segment duration: {entry}"))) + .unwrap_or_else(|_| error!("Invalid segment duration: {entry}")) }) .collect::>();