Skip to content

Commit

Permalink
docstring tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Esgrove committed Dec 26, 2024
1 parent f4cc1b2 commit 48d0639
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/bin/trackprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Tag> {
match Tag::read_from_path(&track.path) {
Expand Down

0 comments on commit 48d0639

Please sign in to comment.