helper: Cleaned up feedback messages

This commit is contained in:
Paul Beckingham 2016-04-04 21:46:09 -04:00
parent 9a4bf75180
commit 05cba6d278
2 changed files with 22 additions and 25 deletions

View file

@ -81,7 +81,7 @@ int CmdStop (
}
else
{
std::string message = "There is no time currently being tracked.";
std::string message = "There is no active time tracking.";
std::cout << message << "\n";
log.write ("warning", message);
}

View file

@ -28,6 +28,7 @@
#include <timew.h>
#include <Duration.h>
#include <sstream>
#include <iomanip>
////////////////////////////////////////////////////////////////////////////////
Color tagColor (const Rules& rules, const std::string& tag)
@ -44,42 +45,38 @@ Color tagColor (const Rules& rules, const std::string& tag)
std::string intervalSummarize (const Rules& rules, const Interval& interval)
{
std::stringstream out;
if (interval.isStarted ())
{
// Combine and colorize tags.
std::string tags;
for (auto& tag : interval.tags ())
{
if (tags != "")
tags += " ";
tags += tagColor (rules, tag).colorize (quoteIfNeeded (tag));
}
// Interval closed.
if (interval.isEnded ())
{
Duration dur (Datetime (interval.end ()) - Datetime (interval.start ()));
out << "Recorded interval from "
<< interval.start ().toISOLocalExtended ()
<< " to "
<< interval.end ().toISOLocalExtended ()
<< " ("
<< dur.format ()
<< ")";
out << "Recorded " << tags << "\n"
<< " Started " << interval.start ().toISOLocalExtended () << "\n"
<< " Ended " << interval.end ().toISOLocalExtended () << "\n"
<< " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << "\n";
}
// Interval open.
else
{
Duration dur (Datetime () - interval.start ());
out << "Active interval since "
<< interval.start ().toISOLocalExtended ();
out << "Tracking " << tags << "\n"
<< " Started " << interval.start ().toISOLocalExtended () << "\n";
if (dur.toTime_t () > 10)
out << " ("
<< dur.format ()
<< ")";
out << " Elapsed " << std::setw (19) << std::setfill (' ') << dur.format () << "\n";
}
// Colorize tags.
auto tags = interval.tags ();
if (tags.size ())
{
out << ", tagged:";
for (auto& tag : tags)
out << ' ' << tagColor (rules, tag).colorize (quoteIfNeeded (tag));
}
out << "\n";
}
return out.str ();