mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
parent
a5493787ad
commit
9aac57c518
1 changed files with 11 additions and 16 deletions
|
@ -39,25 +39,20 @@ int CmdSplit (
|
|||
Database& database,
|
||||
Journal& journal)
|
||||
{
|
||||
const bool verbose = rules.getBoolean ("verbose");
|
||||
std::set <int> ids = cli.getIds ();
|
||||
|
||||
if (ids.empty ())
|
||||
throw std::string ("IDs must be specified. See 'timew help split'.");
|
||||
|
||||
// Load the data.
|
||||
// Note: There is no filter.
|
||||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
journal.startTransaction ();
|
||||
|
||||
// Apply tags to ids.
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
std::vector <Interval> intervals = getIntervalsByIds (database, rules, ids);
|
||||
|
||||
Interval first = tracked[tracked.size () - id];
|
||||
// Apply tags to ids.
|
||||
for (const auto& interval : intervals)
|
||||
{
|
||||
Interval first = interval;
|
||||
Interval second = first;
|
||||
|
||||
if (first.is_open ())
|
||||
|
@ -75,16 +70,16 @@ int CmdSplit (
|
|||
second.start = midpoint;
|
||||
}
|
||||
|
||||
database.deleteInterval (tracked[tracked.size () - id]);
|
||||
database.deleteInterval (interval);
|
||||
|
||||
validate (cli, rules, database, first);
|
||||
database.addInterval (first, rules.getBoolean ("verbose"));
|
||||
database.addInterval (first, verbose);
|
||||
|
||||
validate (cli, rules, database, second);
|
||||
database.addInterval (second, rules.getBoolean ("verbose"));
|
||||
database.addInterval (second, verbose);
|
||||
|
||||
if (rules.getBoolean ("verbose"))
|
||||
std::cout << "Split @" << id << '\n';
|
||||
if (verbose)
|
||||
std::cout << "Split @" << interval.id << '\n';
|
||||
}
|
||||
|
||||
journal.endTransaction ();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue