mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdLengthen: Cleanup
This commit is contained in:
parent
e6c3f76bc3
commit
b14e997ae4
1 changed files with 16 additions and 20 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <Duration.h>
|
||||
#include <format.h>
|
||||
#include <commands.h>
|
||||
#include <timew.h>
|
||||
#include <iostream>
|
||||
|
@ -53,8 +54,6 @@ int CmdLengthen (
|
|||
if (! ids.size ())
|
||||
throw std::string ("IDs must be specified. See 'timew help lengthen'.");
|
||||
|
||||
// TODO Support :adjust
|
||||
|
||||
// Load the data.
|
||||
// Note: There is no filter.
|
||||
Interval filter;
|
||||
|
@ -63,12 +62,14 @@ int CmdLengthen (
|
|||
// Apply tags to ids.
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id <= static_cast <int> (tracked.size ()))
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
// Note: It's okay to subtract a one-based number from a zero-based index.
|
||||
Interval i = tracked[tracked.size () - id];
|
||||
if (! i.range.is_open ())
|
||||
{
|
||||
if (i.range.is_open ())
|
||||
throw format ("Cannot lengthen open interval @{1}", id);
|
||||
|
||||
database.deleteInterval (tracked[tracked.size () - id]);
|
||||
|
||||
Duration dur (delta);
|
||||
|
@ -76,14 +77,9 @@ int CmdLengthen (
|
|||
validate (cli, rules, database, i);
|
||||
database.addInterval (i);
|
||||
|
||||
// Feedback.
|
||||
if (rules.getBoolean ("verbose"))
|
||||
std::cout << "Lengthened @" << id << " by " << dur.formatHours () << '\n';
|
||||
}
|
||||
else
|
||||
std::cout << "Cannot lengthen open interval @" << id << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue