mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdTrack: Implemented simple track
This commit is contained in:
parent
f48bbe0ccf
commit
aed0d02c64
1 changed files with 46 additions and 3 deletions
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <commands.h>
|
#include <commands.h>
|
||||||
|
#include <timew.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -34,12 +35,54 @@ int CmdTrack (
|
||||||
Rules& rules,
|
Rules& rules,
|
||||||
Database& database)
|
Database& database)
|
||||||
{
|
{
|
||||||
std::cout << "[track: record an old interval]\n";
|
|
||||||
|
|
||||||
// TODO Parse interval.
|
// TODO Parse interval.
|
||||||
// TODO Parse tags.
|
// TODO Parse tags.
|
||||||
|
std::string start {""};
|
||||||
|
std::string end {""};
|
||||||
|
std::vector <std::string> tags;
|
||||||
|
for (auto& arg : cli._args)
|
||||||
|
{
|
||||||
|
if (arg.hasTag ("BINARY") ||
|
||||||
|
arg.hasTag ("CMD"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (arg.hasTag ("HINT"))
|
||||||
|
{
|
||||||
|
expandIntervalHint (arg.attribute ("canonical"), start, end);
|
||||||
|
}
|
||||||
|
else if (arg._lextype == Lexer::Type::date)
|
||||||
|
{
|
||||||
|
if (start == "")
|
||||||
|
start = arg.attribute ("raw");
|
||||||
|
else if (end == "")
|
||||||
|
end = arg.attribute ("raw");
|
||||||
|
|
||||||
|
// TODO Is this workable? Using excess date fields as tags. Might just
|
||||||
|
// be a coincidence.
|
||||||
|
else
|
||||||
|
tags.push_back (arg.attribute ("raw"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tags.push_back (arg.attribute ("raw"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Add new interval.
|
// TODO Add new interval.
|
||||||
// TODO Summarize.
|
Interval tracked;
|
||||||
|
tracked.start (Datetime (start));
|
||||||
|
tracked.end (Datetime (end));
|
||||||
|
for (auto& tag : tags)
|
||||||
|
tracked.tag (tag);
|
||||||
|
|
||||||
|
// TODO Apply exclusions.
|
||||||
|
|
||||||
|
// Update database.
|
||||||
|
database.addInterval (tracked);
|
||||||
|
|
||||||
|
// User feedback.
|
||||||
|
if (rules.getBoolean ("verbose"))
|
||||||
|
std::cout << intervalSummarize (rules, tracked);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue