CmdInfo: Code cleanup

This commit is contained in:
Paul Beckingham 2017-01-29 12:22:31 -05:00
parent 8f7ec80666
commit 5915d3834d

View file

@ -66,7 +66,7 @@ CmdInfo::CmdInfo ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int CmdInfo::execute (std::string& output) int CmdInfo::execute (std::string& output)
{ {
int rc = 0; auto rc = 0;
// Apply filter. // Apply filter.
Filter filter; Filter filter;
@ -87,11 +87,11 @@ int CmdInfo::execute (std::string& output)
// Determine the output date format, which uses a hierarchy of definitions. // Determine the output date format, which uses a hierarchy of definitions.
// rc.dateformat.info // rc.dateformat.info
// rc.dateformat // rc.dateformat
std::string dateformat = context.config.get ("dateformat.info"); auto dateformat = context.config.get ("dateformat.info");
if (dateformat == "") if (dateformat == "")
dateformat = context.config.get ("dateformat"); dateformat = context.config.get ("dateformat");
std::string dateformatanno = context.config.get ("dateformat.annotation"); auto dateformatanno = context.config.get ("dateformat.annotation");
if (dateformatanno == "") if (dateformatanno == "")
dateformatanno = dateformat; dateformatanno = dateformat;
@ -122,7 +122,7 @@ int CmdInfo::execute (std::string& output)
Datetime now; Datetime now;
// id // id
int row = view.addRow (); auto row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_ID); view.set (row, 0, STRING_COLUMN_LABEL_ID);
view.set (row, 1, (task.id ? format (task.id) : "-")); view.set (row, 1, (task.id ? format (task.id) : "-"));
@ -131,8 +131,8 @@ int CmdInfo::execute (std::string& output)
// description // description
Color c; Color c;
autoColorize (task, c); autoColorize (task, c);
std::string description = task.get ("description"); auto description = task.get ("description");
int indent = context.config.getInteger ("indent.annotation"); auto indent = context.config.getInteger ("indent.annotation");
for (auto& anno : task.getAnnotations ()) for (auto& anno : task.getAnnotations ())
description += '\n' description += '\n'
@ -227,7 +227,7 @@ int CmdInfo::execute (std::string& output)
std::string entry = dt.toString (dateformat); std::string entry = dt.toString (dateformat);
std::string age; std::string age;
std::string created = task.get ("entry"); auto created = task.get ("entry");
if (created.length ()) if (created.length ())
{ {
Datetime dt (strtol (created.c_str (), NULL, 10)); Datetime dt (strtol (created.c_str (), NULL, 10));
@ -350,7 +350,7 @@ int CmdInfo::execute (std::string& output)
// uuid // uuid
row = view.addRow (); row = view.addRow ();
view.set (row, 0, STRING_COLUMN_LABEL_UUID); view.set (row, 0, STRING_COLUMN_LABEL_UUID);
std::string uuid = task.get ("uuid"); auto uuid = task.get ("uuid");
view.set (row, 1, uuid); view.set (row, 1, uuid);
// Task::urgency // Task::urgency
@ -359,7 +359,7 @@ int CmdInfo::execute (std::string& output)
view.set (row, 1, format (task.urgency (), 4, 4)); view.set (row, 1, format (task.urgency (), 4, 4));
// Show any UDAs // Show any UDAs
std::vector <std::string> all = task.all (); auto all = task.all ();
std::string type; std::string type;
for (auto& att: all) for (auto& att: all)
{ {
@ -368,7 +368,7 @@ int CmdInfo::execute (std::string& output)
Column* col = context.columns[att]; Column* col = context.columns[att];
if (col->is_uda ()) if (col->is_uda ())
{ {
std::string value = task.get (att); auto value = task.get (att);
if (value != "") if (value != "")
{ {
row = view.addRow (); row = view.addRow ();
@ -453,7 +453,7 @@ int CmdInfo::execute (std::string& output)
if (var.first.substr (13, 8) == "project." && if (var.first.substr (13, 8) == "project." &&
(end = var.first.find (".coefficient")) != std::string::npos) (end = var.first.find (".coefficient")) != std::string::npos)
{ {
std::string project = var.first.substr (21, end - 21); auto project = var.first.substr (21, end - 21);
if (task.get ("project").find (project) == 0) if (task.get ("project").find (project) == 0)
urgencyTerm (urgencyDetails, "PROJECT " + project, 1.0, var.second); urgencyTerm (urgencyDetails, "PROJECT " + project, 1.0, var.second);
} }
@ -462,7 +462,7 @@ int CmdInfo::execute (std::string& output)
if (var.first.substr (13, 4) == "tag." && if (var.first.substr (13, 4) == "tag." &&
(end = var.first.find (".coefficient")) != std::string::npos) (end = var.first.find (".coefficient")) != std::string::npos)
{ {
std::string name = var.first.substr (17, end - 17); auto name = var.first.substr (17, end - 17);
if (task.hasTag (name)) if (task.hasTag (name))
urgencyTerm (urgencyDetails, "TAG " + name, 1.0, var.second); urgencyTerm (urgencyDetails, "TAG " + name, 1.0, var.second);
} }
@ -471,7 +471,7 @@ int CmdInfo::execute (std::string& output)
if (var.first.substr (13, 8) == "keyword." && if (var.first.substr (13, 8) == "keyword." &&
(end = var.first.find (".coefficient")) != std::string::npos) (end = var.first.find (".coefficient")) != std::string::npos)
{ {
std::string keyword = var.first.substr (21, end - 21); auto keyword = var.first.substr (21, end - 21);
if (task.get ("description").find (keyword) != std::string::npos) if (task.get ("description").find (keyword) != std::string::npos)
urgencyTerm (urgencyDetails, "KEYWORD " + keyword, 1.0, var.second); urgencyTerm (urgencyDetails, "KEYWORD " + keyword, 1.0, var.second);
} }
@ -485,7 +485,7 @@ int CmdInfo::execute (std::string& output)
auto end = var.first.find (".coefficient"); auto end = var.first.find (".coefficient");
if (end != std::string::npos) if (end != std::string::npos)
{ {
const std::string uda = var.first.substr (12, end - 12); auto uda = var.first.substr (12, end - 12);
auto dot = uda.find ("."); auto dot = uda.find (".");
if (dot == std::string::npos) if (dot == std::string::npos)
{ {
@ -591,10 +591,10 @@ void CmdInfo::urgencyTerm (
float measure, float measure,
float coefficient) const float coefficient) const
{ {
float value = measure * coefficient; auto value = measure * coefficient;
if (value != 0.0) if (value != 0.0)
{ {
int row = view.addRow (); auto row = view.addRow ();
view.set (row, 0, " " + label); view.set (row, 0, " " + label);
view.set (row, 1, rightJustify (format (measure, 5, 3), 6)); view.set (row, 1, rightJustify (format (measure, 5, 3), 6));
view.set (row, 2, "*"); view.set (row, 2, "*");