Don't output empty fields.

This commit is contained in:
tastytea 2021-05-24 16:37:43 +02:00
parent 972ce1d0fe
commit 8b21f4a8b9
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 12 additions and 3 deletions

View File

@ -111,9 +111,18 @@ int main(int argc, char *argv[])
for (const auto &match : search::search(filepath, regex, opts))
{
cout << match.filepath << ", " << match.headline << ", "
<< match.page << ": " << match.context.first
<< match.text << match.context.second << '\n';
cout << match.filepath;
if (!match.headline.empty())
{
cout << ", " << match.headline;
}
if (!match.page.empty())
{
cout << ", " << match.page;
}
cout << ": " << match.context.first << match.text
<< match.context.second << '\n';
}
}
}