From 48d0639ca114a33fd42d849f13d927f6bd3518a0 Mon Sep 17 00:00:00 2001 From: Esgrove Date: Thu, 26 Dec 2024 14:22:42 +0200 Subject: [PATCH] docstring tweaks --- src/bin/trackprint.rs | 1 + src/utils.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/trackprint.rs b/src/bin/trackprint.rs index 15ecdd0..96d59fa 100644 --- a/src/bin/trackprint.rs +++ b/src/bin/trackprint.rs @@ -37,6 +37,7 @@ fn main() -> Result<()> { for track in tracks { println!("{}", track.to_string().bold().magenta()); if let Some(tags) = utils::read_tags(&track, args.verbose || args.debug) { + // Don't print empty tags if tags.frames().count() > 0 { utils::print_tag_data(&tags); serato::print_serato_tags(&tags); diff --git a/src/utils.rs b/src/utils.rs index dfc4ecc..f829fc3 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -237,7 +237,7 @@ pub fn path_to_string(path: &Path) -> String { path.to_str().map_or_else( || { let string = path.to_string_lossy().to_string().replace('\u{FFFD}', ""); - eprintln!("{}", "Path contains invalid unicode".red()); + eprintln!("{}", "Path contains invalid unicode:".red()); eprintln!("{path:?}"); eprintln!("{string}"); string @@ -285,8 +285,12 @@ pub fn print_tag_data(file_tags: &Tag) { .for_each(|string| println!(" {string}")); } -/// Try to read tags from file. -/// Will return empty tags when there are no tags. +/// Try to read tag data from file. +/// +/// Returns empty tags when there is no tag data. +/// If the tag reading fails, +/// returns the partial tag data that was read succesfully before the error occured, +/// or `None` if no tag data could be read. #[must_use] pub fn read_tags(track: &Track, verbose: bool) -> Option { match Tag::read_from_path(&track.path) {