mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Commands: Reduce code duplication
- Extract function to gather ids
This commit is contained in:
parent
c5b2e5a5cd
commit
dc6d3b9672
13 changed files with 70 additions and 81 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue