mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +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
|
@ -39,21 +39,20 @@ int CmdLengthen (
|
|||
Database& database)
|
||||
{
|
||||
// Gather IDs and TAGs.
|
||||
std::vector <int> ids;
|
||||
std::vector <int> ids = cli.getIds();
|
||||
|
||||
if (ids.empty ())
|
||||
throw std::string ("IDs must be specified. See 'timew help lengthen'.");
|
||||
|
||||
std::string delta;
|
||||
|
||||
for (auto& arg : cli._args)
|
||||
{
|
||||
if (arg.hasTag ("ID"))
|
||||
ids.push_back (strtol (arg.attribute ("value").c_str (), NULL, 10));
|
||||
|
||||
if (arg.hasTag ("FILTER") &&
|
||||
arg._lextype == Lexer::Type::duration)
|
||||
delta = arg.attribute ("raw");
|
||||
}
|
||||
|
||||
if (! ids.size ())
|
||||
throw std::string ("IDs must be specified. See 'timew help lengthen'.");
|
||||
|
||||
// Load the data.
|
||||
// Note: There is no filter.
|
||||
Interval filter;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue