Commands: Reduce code duplication

- Extract function to gather ids
This commit is contained in:
Thomas Lauf 2017-11-21 23:12:45 +01:00
parent c5b2e5a5cd
commit dc6d3b9672
13 changed files with 70 additions and 81 deletions

View file

@ -38,13 +38,9 @@ int CmdSplit (
Rules& rules,
Database& database)
{
// Gather IDs and TAGs.
std::vector <int> ids;
for (auto& arg : cli._args)
if (arg.hasTag ("ID"))
ids.push_back (strtol (arg.attribute ("value").c_str (), NULL, 10));
std::vector <int> ids = cli.getIds();
if (! ids.size ())
if (ids.empty ())
throw std::string ("IDs must be specified. See 'timew help split'.");
// Load the data.