Skip to content

Commit

Permalink
specify no tag to dump all tags
Browse files Browse the repository at this point in the history
  • Loading branch information
wfraser committed Oct 28, 2015
1 parent ca0dbcb commit 1654426
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions tools/tag.cpp
Expand Up @@ -12,22 +12,50 @@

int main(int argc, char **argv)
{
if (argc != 3)
char* filename = nullptr;
char* tagname = nullptr;

if (argc == 3)
{
tagname = argv[2];
filename = argv[1];
}
else if (argc == 2)
{
std::cout << "usage: tag <tagname> <filename>\n";
filename = argv[1];
}
else
{
std::cout << "usage: tag [<tagname>] <filename>\n";
return -1;
}

TagLib::FileRef f(argv[2]);
TagLib::FileRef f(filename);

if (f.file() == nullptr)
{
std::cout << "no tags\n";
return 0;
}

std::cout << f.file()->properties()[argv[1]].toString().to8Bit(true)
<< std::endl;
if (tagname != nullptr)
{
std::cout << f.file()->properties()[tagname].toString().to8Bit(true)
<< std::endl;
}
else
{
const TagLib::PropertyMap properties = f.file()->properties();

for (const auto& pair : properties)
{
const TagLib::String& name = pair.first;
const TagLib::StringList& value = pair.second;

std::cout << name.to8Bit(true) << "\t"
<< value.toString().to8Bit(true) << std::endl;
}
}

return 0;
}

0 comments on commit 1654426

Please sign in to comment.