cli: Display at least MIME-type if field cannot be displayed as string

This commit is contained in:
Martchus 2022-03-16 19:38:51 +01:00
parent feb4180fa3
commit 7ba63ad79f
2 changed files with 12 additions and 11 deletions

View File

@ -262,7 +262,8 @@ static void printTagValue(const TagValue &value)
cout << value.toString(TagTextEncoding::Utf8);
} catch (const ConversionException &) {
// handle case when value can not be displayed as string
cout << "can't display as string (see --extract)";
const auto type = !value.mimeType().empty() ? std::string_view(value.mimeType()) : std::string_view("data");
cout << "can't display " << type << " as string (use --extract)";
}
cout << '\n';
}

View File

@ -263,12 +263,12 @@ void CliTests::testModifyingCover()
CPPUNIT_ASSERT_MESSAGE("covers added",
testContainsSubstrings(stdout,
{ " - \e[1mID3v2 tag (version 2.3.0)\e[0m\n", " Lyrics I\nam\nno\nsong\nwriter\n",
" Cover (other) can't display as string (see --extract)\n"
" Cover (front-cover) can't display as string (see --extract)\n"
" Cover (other) can't display image/png as string (use --extract)\n"
" Cover (front-cover) can't display image/png as string (use --extract)\n"
" description: foo\n"
" Cover (front-cover) can't display as string (see --extract)\n"
" Cover (front-cover) can't display image/png as string (use --extract)\n"
" description: bar\n"
" Cover (back-cover) can't display as string (see --extract)\n" }));
" Cover (back-cover) can't display image/png as string (use --extract)\n" }));
CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1Backup.data()));
// test whether empty trailing ":" does *not* affect all descriptions
@ -279,12 +279,12 @@ void CliTests::testModifyingCover()
testContainsSubstrings(stdout,
{
" - \e[1mID3v2 tag (version 2.3.0)\e[0m\n",
" Cover (other) can't display as string (see --extract)\n"
" Cover (front-cover) can't display as string (see --extract)\n"
" Cover (other) can't display image/png as string (use --extract)\n"
" Cover (front-cover) can't display image/png as string (use --extract)\n"
" description: foo\n"
" Cover (front-cover) can't display as string (see --extract)\n"
" Cover (front-cover) can't display image/png as string (use --extract)\n"
" description: bar\n"
" Cover (back-cover) can't display as string (see --extract)\n",
" Cover (back-cover) can't display image/png as string (use --extract)\n",
}));
CPPUNIT_ASSERT_EQUAL(-1, remove(mp3File1Backup.data()));
@ -297,8 +297,8 @@ void CliTests::testModifyingCover()
testContainsSubstrings(stdout,
{
" - \e[1mID3v2 tag (version 2.3.0)\e[0m\n",
" Cover (other) can't display as string (see --extract)\n"
" Cover (back-cover) can't display as string (see --extract)\n",
" Cover (other) can't display image/png as string (use --extract)\n"
" Cover (back-cover) can't display image/png as string (use --extract)\n",
}));
CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1Backup.data()));