mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Cleanup: Don't use string literals when character literals are needed
This commit is contained in:
parent
95f4989f77
commit
8922728888
27 changed files with 122 additions and 122 deletions
|
@ -72,9 +72,9 @@ std::string Msg::serialize () const
|
||||||
{
|
{
|
||||||
std::string output;
|
std::string output;
|
||||||
for (auto& i : _header)
|
for (auto& i : _header)
|
||||||
output += i.first + ": " + i.second + "\n";
|
output += i.first + ": " + i.second + '\n';
|
||||||
|
|
||||||
output += "\n" + _payload + "\n";
|
output += '\n' + _payload + '\n';
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ bool Msg::parse (const std::string& input)
|
||||||
{
|
{
|
||||||
auto delimiter = i.find (':');
|
auto delimiter = i.find (':');
|
||||||
if (delimiter == std::string::npos)
|
if (delimiter == std::string::npos)
|
||||||
throw std::string ("ERROR: Malformed message header '") + i + "'";
|
throw std::string ("ERROR: Malformed message header '") + i + '\'';
|
||||||
|
|
||||||
_header[Lexer::trim (i.substr (0, delimiter))] = Lexer::trim (i.substr (delimiter + 1));
|
_header[Lexer::trim (i.substr (0, delimiter))] = Lexer::trim (i.substr (delimiter + 1));
|
||||||
}
|
}
|
||||||
|
|
60
src/TDB2.cpp
60
src/TDB2.cpp
|
@ -61,7 +61,7 @@ TF2::~TF2 ()
|
||||||
{
|
{
|
||||||
if (_dirty && TDB2::debug_mode)
|
if (_dirty && TDB2::debug_mode)
|
||||||
std::cout << format (STRING_TDB2_DIRTY_EXIT, std::string (_file))
|
std::cout << format (STRING_TDB2_DIRTY_EXIT, std::string (_file))
|
||||||
<< "\n";
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -301,7 +301,7 @@ void TF2::commit ()
|
||||||
for (auto& task : _tasks)
|
for (auto& task : _tasks)
|
||||||
// Skip over the tasks that are marked to be purged
|
// Skip over the tasks that are marked to be purged
|
||||||
if (_purged_tasks.find (task.get ("uuid")) == _purged_tasks.end ())
|
if (_purged_tasks.find (task.get ("uuid")) == _purged_tasks.end ())
|
||||||
_file.write_raw (task.composeF4 () + "\n");
|
_file.write_raw (task.composeF4 () + '\n');
|
||||||
|
|
||||||
// Write out all the added lines.
|
// Write out all the added lines.
|
||||||
_file.append (_added_lines);
|
_file.append (_added_lines);
|
||||||
|
@ -708,9 +708,9 @@ void TDB2::update (
|
||||||
// old <task>
|
// old <task>
|
||||||
// new <task>
|
// new <task>
|
||||||
// ---
|
// ---
|
||||||
undo.add_line ("time " + ISO8601d ().toEpochString () + "\n");
|
undo.add_line ("time " + ISO8601d ().toEpochString () + '\n');
|
||||||
undo.add_line ("old " + original.composeF4 () + "\n");
|
undo.add_line ("old " + original.composeF4 () + '\n');
|
||||||
undo.add_line ("new " + task.composeF4 () + "\n");
|
undo.add_line ("new " + task.composeF4 () + '\n');
|
||||||
undo.add_line ("---\n");
|
undo.add_line ("---\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -727,14 +727,14 @@ void TDB2::update (
|
||||||
// time <time>
|
// time <time>
|
||||||
// new <task>
|
// new <task>
|
||||||
// ---
|
// ---
|
||||||
undo.add_line ("time " + ISO8601d ().toEpochString () + "\n");
|
undo.add_line ("time " + ISO8601d ().toEpochString () + '\n');
|
||||||
undo.add_line ("new " + task.composeF4 () + "\n");
|
undo.add_line ("new " + task.composeF4 () + '\n');
|
||||||
undo.add_line ("---\n");
|
undo.add_line ("---\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add task to backlog.
|
// Add task to backlog.
|
||||||
if (add_to_backlog)
|
if (add_to_backlog)
|
||||||
backlog.add_line (task.composeJSON () + "\n");
|
backlog.add_line (task.composeJSON () + '\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -861,7 +861,7 @@ void TDB2::revert ()
|
||||||
File::write (backlog._file._data, b);
|
File::write (backlog._file._data, b);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cout << STRING_CMD_CONFIG_NO_CHANGE << "\n";
|
std::cout << STRING_CMD_CONFIG_NO_CHANGE << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -909,7 +909,7 @@ void TDB2::revert_pending (
|
||||||
const std::string& uuid,
|
const std::string& uuid,
|
||||||
const std::string& prior)
|
const std::string& prior)
|
||||||
{
|
{
|
||||||
std::string uuid_att = "uuid:\"" + uuid + "\"";
|
std::string uuid_att = "uuid:\"" + uuid + '"';
|
||||||
|
|
||||||
// is 'current' in pending?
|
// is 'current' in pending?
|
||||||
for (auto task = p.begin (); task != p.end (); ++task)
|
for (auto task = p.begin (); task != p.end (); ++task)
|
||||||
|
@ -922,12 +922,12 @@ void TDB2::revert_pending (
|
||||||
if (prior != "")
|
if (prior != "")
|
||||||
{
|
{
|
||||||
*task = prior;
|
*task = prior;
|
||||||
std::cout << STRING_TDB2_REVERTED << "\n";
|
std::cout << STRING_TDB2_REVERTED << '\n';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.erase (task);
|
p.erase (task);
|
||||||
std::cout << STRING_TDB2_REMOVED << "\n";
|
std::cout << STRING_TDB2_REMOVED << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -942,7 +942,7 @@ void TDB2::revert_completed (
|
||||||
const std::string& uuid,
|
const std::string& uuid,
|
||||||
const std::string& prior)
|
const std::string& prior)
|
||||||
{
|
{
|
||||||
std::string uuid_att = "uuid:\"" + uuid + "\"";
|
std::string uuid_att = "uuid:\"" + uuid + '"';
|
||||||
|
|
||||||
// is 'current' in completed?
|
// is 'current' in completed?
|
||||||
for (auto task = c.begin (); task != c.end (); ++task)
|
for (auto task = c.begin (); task != c.end (); ++task)
|
||||||
|
@ -961,12 +961,12 @@ void TDB2::revert_completed (
|
||||||
{
|
{
|
||||||
c.erase (task);
|
c.erase (task);
|
||||||
p.push_back (prior);
|
p.push_back (prior);
|
||||||
std::cout << STRING_TDB2_REVERTED << "\n";
|
std::cout << STRING_TDB2_REVERTED << '\n';
|
||||||
context.debug ("TDB::revert_completed - task belongs in pending.data");
|
context.debug ("TDB::revert_completed - task belongs in pending.data");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << STRING_TDB2_REVERTED << "\n";
|
std::cout << STRING_TDB2_REVERTED << '\n';
|
||||||
context.debug ("TDB::revert_completed - task belongs in completed.data");
|
context.debug ("TDB::revert_completed - task belongs in completed.data");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -974,11 +974,11 @@ void TDB2::revert_completed (
|
||||||
{
|
{
|
||||||
c.erase (task);
|
c.erase (task);
|
||||||
|
|
||||||
std::cout << STRING_TDB2_REVERTED << "\n";
|
std::cout << STRING_TDB2_REVERTED << '\n';
|
||||||
context.debug ("TDB::revert_completed - task removed");
|
context.debug ("TDB::revert_completed - task removed");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << STRING_TDB2_UNDO_COMPLETE << "\n";
|
std::cout << STRING_TDB2_UNDO_COMPLETE << '\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -991,7 +991,7 @@ void TDB2::revert_backlog (
|
||||||
const std::string& current,
|
const std::string& current,
|
||||||
const std::string& prior)
|
const std::string& prior)
|
||||||
{
|
{
|
||||||
std::string uuid_att = "\"uuid\":\"" + uuid + "\"";
|
std::string uuid_att = "\"uuid\":\"" + uuid + '"';
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto task = b.rbegin (); task != b.rend (); ++task)
|
for (auto task = b.rbegin (); task != b.rend (); ++task)
|
||||||
|
@ -1038,9 +1038,9 @@ void TDB2::show_diff (
|
||||||
|
|
||||||
if (context.config.get ("undo.style") == "side")
|
if (context.config.get ("undo.style") == "side")
|
||||||
{
|
{
|
||||||
std::cout << "\n"
|
std::cout << '\n'
|
||||||
<< format (STRING_TDB2_LAST_MOD, lastChange.toString ())
|
<< format (STRING_TDB2_LAST_MOD, lastChange.toString ())
|
||||||
<< "\n";
|
<< '\n';
|
||||||
|
|
||||||
// Attributes are all there is, so figure the different attribute names
|
// Attributes are all there is, so figure the different attribute names
|
||||||
// between before and after.
|
// between before and after.
|
||||||
|
@ -1114,9 +1114,9 @@ void TDB2::show_diff (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\n"
|
std::cout << '\n'
|
||||||
<< view.render ()
|
<< view.render ()
|
||||||
<< "\n";
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// This style looks like this:
|
// This style looks like this:
|
||||||
|
@ -1203,21 +1203,21 @@ void TDB2::show_diff (
|
||||||
else if (before_att != "" && after_att == "")
|
else if (before_att != "" && after_att == "")
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "-" + a + ":", color_red);
|
view.set (row, 0, '-' + a + ':', color_red);
|
||||||
view.set (row, 1, before_att, color_red);
|
view.set (row, 1, before_att, color_red);
|
||||||
|
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "+" + a + ":", color_green);
|
view.set (row, 0, '+' + a + ':', color_green);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attribute added.
|
// Attribute added.
|
||||||
else if (before_att == "" && after_att != "")
|
else if (before_att == "" && after_att != "")
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "-" + a + ":", color_red);
|
view.set (row, 0, '-' + a + ':', color_red);
|
||||||
|
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "+" + a + ":", color_green);
|
view.set (row, 0, '+' + a + ':', color_green);
|
||||||
view.set (row, 1, after_att, color_green);
|
view.set (row, 1, after_att, color_green);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,19 +1225,19 @@ void TDB2::show_diff (
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "-" + a + ":", color_red);
|
view.set (row, 0, '-' + a + ':', color_red);
|
||||||
view.set (row, 1, before_att, color_red);
|
view.set (row, 1, before_att, color_red);
|
||||||
|
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "+" + a + ":", color_green);
|
view.set (row, 0, '+' + a + ':', color_green);
|
||||||
view.set (row, 1, after_att, color_green);
|
view.set (row, 1, after_att, color_green);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "\n"
|
std::cout << '\n'
|
||||||
<< view.render ()
|
<< view.render ()
|
||||||
<< "\n";
|
<< '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
src/Task.cpp
58
src/Task.cpp
|
@ -799,7 +799,7 @@ void Task::parseLegacy (const std::string& line)
|
||||||
std::stringstream message;
|
std::stringstream message;
|
||||||
message << "Invalid fileformat at line '"
|
message << "Invalid fileformat at line '"
|
||||||
<< line
|
<< line
|
||||||
<< "'";
|
<< '\'';
|
||||||
context.debug (message.str ());
|
context.debug (message.str ());
|
||||||
#endif
|
#endif
|
||||||
throw std::string (STRING_TASK_PARSE_UNREC_FF);
|
throw std::string (STRING_TASK_PARSE_UNREC_FF);
|
||||||
|
@ -836,13 +836,13 @@ std::string Task::composeF4 () const
|
||||||
ff4 += encode (json::encode (it.second));
|
ff4 += encode (json::encode (it.second));
|
||||||
else
|
else
|
||||||
ff4 += it.second;
|
ff4 += it.second;
|
||||||
ff4 += "\"";
|
ff4 += '"';
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ff4 += "]";
|
ff4 += ']';
|
||||||
return ff4;
|
return ff4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,12 +850,12 @@ std::string Task::composeF4 () const
|
||||||
std::string Task::composeJSON (bool decorate /*= false*/) const
|
std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
{
|
{
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
out << "{";
|
out << '{';
|
||||||
|
|
||||||
// ID inclusion is optional, but not a good idea, because it remains correct
|
// ID inclusion is optional, but not a good idea, because it remains correct
|
||||||
// only until the next gc.
|
// only until the next gc.
|
||||||
if (decorate)
|
if (decorate)
|
||||||
out << "\"id\":" << id << ",";
|
out << "\"id\":" << id << ',';
|
||||||
|
|
||||||
// First the non-annotations.
|
// First the non-annotations.
|
||||||
int attributes_written = 0;
|
int attributes_written = 0;
|
||||||
|
@ -870,7 +870,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (attributes_written)
|
if (attributes_written)
|
||||||
out << ",";
|
out << ',';
|
||||||
|
|
||||||
std::string type = Task::attributes[i.first];
|
std::string type = Task::attributes[i.first];
|
||||||
if (type == "")
|
if (type == "")
|
||||||
|
@ -880,12 +880,12 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
if (type == "date")
|
if (type == "date")
|
||||||
{
|
{
|
||||||
ISO8601d d (i.second);
|
ISO8601d d (i.second);
|
||||||
out << "\""
|
out << '"'
|
||||||
<< (i.first == "modification" ? "modified" : i.first)
|
<< (i.first == "modification" ? "modified" : i.first)
|
||||||
<< "\":\""
|
<< "\":\""
|
||||||
// Date was deleted, do not export parsed empty string
|
// Date was deleted, do not export parsed empty string
|
||||||
<< (i.second == "" ? "" : d.toISO ())
|
<< (i.second == "" ? "" : d.toISO ())
|
||||||
<< "\"";
|
<< '"';
|
||||||
|
|
||||||
++attributes_written;
|
++attributes_written;
|
||||||
}
|
}
|
||||||
|
@ -898,7 +898,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
*/
|
*/
|
||||||
else if (type == "numeric")
|
else if (type == "numeric")
|
||||||
{
|
{
|
||||||
out << "\""
|
out << '"'
|
||||||
<< i.first
|
<< i.first
|
||||||
<< "\":"
|
<< "\":"
|
||||||
<< i.second;
|
<< i.second;
|
||||||
|
@ -918,12 +918,12 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
for (auto i : tags)
|
for (auto i : tags)
|
||||||
{
|
{
|
||||||
if (count++)
|
if (count++)
|
||||||
out << ",";
|
out << ',';
|
||||||
|
|
||||||
out << "\"" << i << "\"";
|
out << '"' << i << '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "]";
|
out << ']';
|
||||||
++attributes_written;
|
++attributes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,23 +958,23 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
for (auto i : deps)
|
for (auto i : deps)
|
||||||
{
|
{
|
||||||
if (count++)
|
if (count++)
|
||||||
out << ",";
|
out << ',';
|
||||||
|
|
||||||
out << "\"" << i << "\"";
|
out << '"' << i << '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "]";
|
out << ']';
|
||||||
++attributes_written;
|
++attributes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Everything else is a quoted value.
|
// Everything else is a quoted value.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << "\""
|
out << '"'
|
||||||
<< i.first
|
<< i.first
|
||||||
<< "\":\""
|
<< "\":\""
|
||||||
<< (type == "string" ? json::encode (i.second) : i.second)
|
<< (type == "string" ? json::encode (i.second) : i.second)
|
||||||
<< "\"";
|
<< '"';
|
||||||
|
|
||||||
++attributes_written;
|
++attributes_written;
|
||||||
}
|
}
|
||||||
|
@ -983,7 +983,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
// Now the annotations, if any.
|
// Now the annotations, if any.
|
||||||
if (annotation_count)
|
if (annotation_count)
|
||||||
{
|
{
|
||||||
out << ","
|
out << ','
|
||||||
<< "\"annotations\":[";
|
<< "\"annotations\":[";
|
||||||
|
|
||||||
int annotations_written = 0;
|
int annotations_written = 0;
|
||||||
|
@ -992,7 +992,7 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
if (! i.first.compare (0, 11, "annotation_", 11))
|
if (! i.first.compare (0, 11, "annotation_", 11))
|
||||||
{
|
{
|
||||||
if (annotations_written)
|
if (annotations_written)
|
||||||
out << ",";
|
out << ',';
|
||||||
|
|
||||||
ISO8601d d (i.first.substr (11));
|
ISO8601d d (i.first.substr (11));
|
||||||
out << "{\"entry\":\""
|
out << "{\"entry\":\""
|
||||||
|
@ -1005,18 +1005,18 @@ std::string Task::composeJSON (bool decorate /*= false*/) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out << "]";
|
out << ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PRODUCT_TASKWARRIOR
|
#ifdef PRODUCT_TASKWARRIOR
|
||||||
// Include urgency.
|
// Include urgency.
|
||||||
if (decorate)
|
if (decorate)
|
||||||
out << ","
|
out << ','
|
||||||
<< "\"urgency\":"
|
<< "\"urgency\":"
|
||||||
<< urgency_c ();
|
<< urgency_c ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
out << "}";
|
out << '}';
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1123,7 +1123,7 @@ void Task::addDependency (const std::string& uuid)
|
||||||
{
|
{
|
||||||
// Check for extant dependency.
|
// Check for extant dependency.
|
||||||
if (depends.find (uuid) == std::string::npos)
|
if (depends.find (uuid) == std::string::npos)
|
||||||
set ("depends", depends + "," + uuid);
|
set ("depends", depends + ',' + uuid);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PRODUCT_TASKWARRIOR
|
#ifdef PRODUCT_TASKWARRIOR
|
||||||
|
@ -1828,7 +1828,7 @@ float Task::urgency_c () const
|
||||||
if (end != std::string::npos)
|
if (end != std::string::npos)
|
||||||
{
|
{
|
||||||
const std::string uda = var.first.substr (12, end - 12);
|
const std::string 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)
|
||||||
{
|
{
|
||||||
// urgency.uda.<name>.coefficient
|
// urgency.uda.<name>.coefficient
|
||||||
|
@ -2106,13 +2106,13 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
|
|
||||||
if (a.attribute ("sign") == "+")
|
if (a.attribute ("sign") == "+")
|
||||||
{
|
{
|
||||||
context.debug (label + "tags <-- add '" + tag + "'");
|
context.debug (label + "tags <-- add '" + tag + '\'');
|
||||||
addTag (tag);
|
addTag (tag);
|
||||||
feedback_special_tags (*this, tag);
|
feedback_special_tags (*this, tag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.debug (label + "tags <-- remove '" + tag + "'");
|
context.debug (label + "tags <-- remove '" + tag + '\'');
|
||||||
removeTag (tag);
|
removeTag (tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2138,7 +2138,7 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case modReplace:
|
case modReplace:
|
||||||
context.debug (label + "description <-- '" + text + "'");
|
context.debug (label + "description <-- '" + text + '\'');
|
||||||
set ("description", text);
|
set ("description", text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2148,12 +2148,12 @@ void Task::modify (modType type, bool text_required /* = false */)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case modAppend:
|
case modAppend:
|
||||||
context.debug (label + "description <-- description + '" + text + "'");
|
context.debug (label + "description <-- description + '" + text + '\'');
|
||||||
set ("description", get ("description") + ' ' + text);
|
set ("description", get ("description") + ' ' + text);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case modAnnotate:
|
case modAnnotate:
|
||||||
context.debug (label + "new annotation <-- '" + text + "'");
|
context.debug (label + "new annotation <-- '" + text + '\'');
|
||||||
addAnnotation (text);
|
addAnnotation (text);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ void ColumnDepends::render (
|
||||||
dependencyGetBlocking (task, blocking);
|
dependencyGetBlocking (task, blocking);
|
||||||
|
|
||||||
if (_style == "count")
|
if (_style == "count")
|
||||||
renderStringRight (lines, width, color, "[" + format (static_cast <int>(blocking.size ())) + "]");
|
renderStringRight (lines, width, color, '[' + format (static_cast <int>(blocking.size ())) + ']');
|
||||||
|
|
||||||
else if (_style == "default" ||
|
else if (_style == "default" ||
|
||||||
_style == "list")
|
_style == "list")
|
||||||
|
|
|
@ -238,7 +238,7 @@ void ColumnDescription::render (
|
||||||
else if (_style == "count")
|
else if (_style == "count")
|
||||||
{
|
{
|
||||||
if (task.annotation_count)
|
if (task.annotation_count)
|
||||||
description += " [" + format (task.annotation_count) + "]";
|
description += " [" + format (task.annotation_count) + ']';
|
||||||
|
|
||||||
std::vector <std::string> raw;
|
std::vector <std::string> raw;
|
||||||
wrapText (raw, description, width, _hyphenate);
|
wrapText (raw, description, width, _hyphenate);
|
||||||
|
@ -256,7 +256,7 @@ void ColumnDescription::render (
|
||||||
int len_annos = 0;
|
int len_annos = 0;
|
||||||
if (task.annotation_count)
|
if (task.annotation_count)
|
||||||
{
|
{
|
||||||
annos_count = " [" + format (task.annotation_count) + "]";
|
annos_count = " [" + format (task.annotation_count) + ']';
|
||||||
len_annos = utf8_width (annos_count);
|
len_annos = utf8_width (annos_count);
|
||||||
len += len_annos;
|
len += len_annos;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
|
||||||
Variant v;
|
Variant v;
|
||||||
e.evaluateInfixExpression (value, v);
|
e.evaluateInfixExpression (value, v);
|
||||||
task.set (_name, (std::string) v);
|
task.set (_name, (std::string) v);
|
||||||
context.debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + (std::string) v + "' <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
catch (const std::string& e)
|
catch (const std::string& e)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +143,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
|
||||||
if (e == STRING_EVAL_NOT_EXPRESSION)
|
if (e == STRING_EVAL_NOT_EXPRESSION)
|
||||||
{
|
{
|
||||||
task.set (_name, value);
|
task.set (_name, value);
|
||||||
context.debug (label + _name + " <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw;
|
throw;
|
||||||
|
@ -152,7 +152,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
task.set (_name, value);
|
task.set (_name, value);
|
||||||
context.debug (label + _name + " <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void ColumnRecur::modify (Task& task, const std::string& value)
|
||||||
{
|
{
|
||||||
// Store the raw value, for 'recur'.
|
// Store the raw value, for 'recur'.
|
||||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||||
context.debug (label + _name + " <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + value + '\'');
|
||||||
task.set (_name, value);
|
task.set (_name, value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -154,7 +154,7 @@ void ColumnTags::render (
|
||||||
{
|
{
|
||||||
std::vector <std::string> all;
|
std::vector <std::string> all;
|
||||||
split (all, tags, ',');
|
split (all, tags, ',');
|
||||||
renderStringRight (lines, width, color, "[" + format (static_cast <int> (all.size ())) + "]");
|
renderStringRight (lines, width, color, '[' + format (static_cast <int> (all.size ())) + ']');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,12 +187,12 @@ void ColumnTags::modify (Task& task, const std::string& value)
|
||||||
Variant v;
|
Variant v;
|
||||||
e.evaluateInfixExpression (value, v);
|
e.evaluateInfixExpression (value, v);
|
||||||
task.addTag ((std::string) v);
|
task.addTag ((std::string) v);
|
||||||
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + "'");
|
context.debug (label + "tags <-- '" + (std::string) v + "' <-- '" + tag + '\'');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
task.addTag (tag);
|
task.addTag (tag);
|
||||||
context.debug (label + "tags <-- '" + tag + "'");
|
context.debug (label + "tags <-- '" + tag + '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
feedback_special_tags (task, tag);
|
feedback_special_tags (task, tag);
|
||||||
|
|
|
@ -61,7 +61,7 @@ ColumnTypeDate::ColumnTypeDate ()
|
||||||
now.toEpochString (),
|
now.toEpochString (),
|
||||||
now.toISO (),
|
now.toISO (),
|
||||||
ISO8601p (ISO8601d () - now).formatVague (),
|
ISO8601p (ISO8601d () - now).formatVague (),
|
||||||
"-" + ISO8601p (ISO8601d () - now).formatVague (),
|
'-' + ISO8601p (ISO8601d () - now).formatVague (),
|
||||||
"",
|
"",
|
||||||
ISO8601p (ISO8601d () - now).format ()};
|
ISO8601p (ISO8601d () - now).format ()};
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ void ColumnTypeDate::render (
|
||||||
if (now > date)
|
if (now > date)
|
||||||
renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ());
|
renderStringLeft (lines, width, color, ISO8601p (now - date).formatVague ());
|
||||||
else
|
else
|
||||||
renderStringLeft (lines, width, color, "-" + ISO8601p (date - now).formatVague ());
|
renderStringLeft (lines, width, color, '-' + ISO8601p (date - now).formatVague ());
|
||||||
}
|
}
|
||||||
else if (_style == "relative")
|
else if (_style == "relative")
|
||||||
{
|
{
|
||||||
|
@ -191,7 +191,7 @@ void ColumnTypeDate::render (
|
||||||
if (now < date)
|
if (now < date)
|
||||||
renderStringLeft (lines, width, color, ISO8601p (date - now).formatVague ());
|
renderStringLeft (lines, width, color, ISO8601p (date - now).formatVague ());
|
||||||
else
|
else
|
||||||
renderStringLeft (lines, width, color, "-" + ISO8601p (now - date).formatVague ());
|
renderStringLeft (lines, width, color, '-' + ISO8601p (now - date).formatVague ());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (_style == "remaining")
|
else if (_style == "remaining")
|
||||||
|
@ -226,7 +226,7 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
|
||||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||||
if (evaluatedValue.type () == Variant::type_duration)
|
if (evaluatedValue.type () == Variant::type_duration)
|
||||||
{
|
{
|
||||||
context.debug (label + _name + " <-- '" + format ("{1}", format (evaluatedValue.get_duration ())) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + format ("{1}", format (evaluatedValue.get_duration ())) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
|
||||||
Variant now;
|
Variant now;
|
||||||
if (namedDates ("now", now))
|
if (namedDates ("now", now))
|
||||||
evaluatedValue += now;
|
evaluatedValue += now;
|
||||||
|
@ -234,7 +234,7 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
evaluatedValue.cast (Variant::type_date);
|
evaluatedValue.cast (Variant::type_date);
|
||||||
context.debug (label + _name + " <-- '" + format ("{1}", evaluatedValue.get_date ()) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + format ("{1}", evaluatedValue.get_date ()) + "' <-- '" + (std::string) evaluatedValue + "' <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a date doesn't parse (2/29/2014) then it evaluates to zero.
|
// If a date doesn't parse (2/29/2014) then it evaluates to zero.
|
||||||
|
|
|
@ -68,7 +68,7 @@ void ColumnTypeDuration::modify (Task& task, const std::string& value)
|
||||||
if (evaluatedValue.type () == Variant::type_duration)
|
if (evaluatedValue.type () == Variant::type_duration)
|
||||||
{
|
{
|
||||||
// Store the raw value, for 'recur'.
|
// Store the raw value, for 'recur'.
|
||||||
context.debug (label + _name + " <-- " + (std::string) evaluatedValue + " <-- '" + value + "'");
|
context.debug (label + _name + " <-- " + (std::string) evaluatedValue + " <-- '" + value + '\'');
|
||||||
task.set (_name, evaluatedValue);
|
task.set (_name, evaluatedValue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -63,7 +63,7 @@ void ColumnTypeNumeric::modify (Task& task, const std::string& value)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string label = " [1;37;43mMODIFICATION[0m ";
|
std::string label = " [1;37;43mMODIFICATION[0m ";
|
||||||
context.debug (label + _name + " <-- '" + evaluatedValue.get_string () + "' <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + evaluatedValue.get_string () + "' <-- '" + value + '\'');
|
||||||
|
|
||||||
// If the result is not readily convertible to a numeric value, then this is
|
// If the result is not readily convertible to a numeric value, then this is
|
||||||
// an error.
|
// an error.
|
||||||
|
|
|
@ -66,7 +66,7 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
|
||||||
if (validate (strValue))
|
if (validate (strValue))
|
||||||
{
|
{
|
||||||
task.set (_name, strValue);
|
task.set (_name, strValue);
|
||||||
context.debug (label + _name + " <-- '" + strValue + "' <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + strValue + "' <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_INVALID_MOD, _name, value);
|
throw format (STRING_INVALID_MOD, _name, value);
|
||||||
|
@ -76,7 +76,7 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
|
||||||
if (validate (value))
|
if (validate (value))
|
||||||
{
|
{
|
||||||
task.set (_name, value);
|
task.set (_name, value);
|
||||||
context.debug (label + _name + " <-- '" + value + "'");
|
context.debug (label + _name + " <-- '" + value + '\'');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw format (STRING_INVALID_MOD, _name, value);
|
throw format (STRING_INVALID_MOD, _name, value);
|
||||||
|
|
|
@ -60,7 +60,7 @@ int CmdZshAttributes::execute (std::string& output)
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (auto& col : columns)
|
for (auto& col : columns)
|
||||||
out << col << ":" << col << '\n';
|
out << col << ':' << col << '\n';
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -214,7 +214,7 @@ Chart::Chart (char type)
|
||||||
std::vector <std::string> words = context.cli2.getWords ();
|
std::vector <std::string> words = context.cli2.getWords ();
|
||||||
std::string filter;
|
std::string filter;
|
||||||
join (filter, " ", words);
|
join (filter, " ", words);
|
||||||
_title = "(" + filter + ")";
|
_title = '(' + filter + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -860,7 +860,7 @@ void Chart::calculateRates ()
|
||||||
_completion = end.toString (format)
|
_completion = end.toString (format)
|
||||||
+ " ("
|
+ " ("
|
||||||
+ delta.formatVague ()
|
+ delta.formatVague ()
|
||||||
+ ")";
|
+ ')';
|
||||||
|
|
||||||
std::stringstream completion_message;
|
std::stringstream completion_message;
|
||||||
completion_message << "Chart::calculateRates ("
|
completion_message << "Chart::calculateRates ("
|
||||||
|
|
|
@ -224,8 +224,8 @@ int CmdZshCommands::execute (std::string& output)
|
||||||
// Emit the commands in order.
|
// Emit the commands in order.
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (auto& zc : commands)
|
for (auto& zc : commands)
|
||||||
out << zc._command << ":"
|
out << zc._command << ':'
|
||||||
<< Command::categoryNames.at (zc._category) << ":"
|
<< Command::categoryNames.at (zc._category) << ':'
|
||||||
<< zc._description << '\n';
|
<< zc._description << '\n';
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
|
|
|
@ -65,8 +65,8 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
||||||
for (auto& line : contents)
|
for (auto& line : contents)
|
||||||
{
|
{
|
||||||
// If there is a comment on the line, it must follow the pattern.
|
// If there is a comment on the line, it must follow the pattern.
|
||||||
auto comment = line.find ("#");
|
auto comment = line.find ('#');
|
||||||
auto pos = line.find (name + "=");
|
auto pos = line.find (name + '=');
|
||||||
|
|
||||||
if (pos != std::string::npos &&
|
if (pos != std::string::npos &&
|
||||||
(comment == std::string::npos ||
|
(comment == std::string::npos ||
|
||||||
|
@ -77,9 +77,9 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
||||||
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
confirm (format (STRING_CMD_CONFIG_CONFIRM, name, context.config.get (name), value)))
|
||||||
{
|
{
|
||||||
if (comment != std::string::npos)
|
if (comment != std::string::npos)
|
||||||
line = name + "=" + json::encode (value) + ' ' + line.substr (comment);
|
line = name + '=' + json::encode (value) + ' ' + line.substr (comment);
|
||||||
else
|
else
|
||||||
line = name + "=" + json::encode (value);
|
line = name + '=' + json::encode (value);
|
||||||
|
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ bool CmdConfig::setConfigVariable (std::string name, std::string value, bool con
|
||||||
(!confirmation ||
|
(!confirmation ||
|
||||||
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
|
confirm (format (STRING_CMD_CONFIG_CONFIRM2, name, value))))
|
||||||
{
|
{
|
||||||
contents.push_back (name + "=" + json::encode (value));
|
contents.push_back (name + '=' + json::encode (value));
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,8 +116,8 @@ int CmdConfig::unsetConfigVariable (std::string name, bool confirmation /* = fal
|
||||||
bool lineDeleted = false;
|
bool lineDeleted = false;
|
||||||
|
|
||||||
// If there is a comment on the line, it must follow the pattern.
|
// If there is a comment on the line, it must follow the pattern.
|
||||||
auto comment = line->find ("#");
|
auto comment = line->find ('#');
|
||||||
auto pos = line->find (name + "=");
|
auto pos = line->find (name + '=');
|
||||||
|
|
||||||
if (pos != std::string::npos &&
|
if (pos != std::string::npos &&
|
||||||
(comment == std::string::npos ||
|
(comment == std::string::npos ||
|
||||||
|
|
|
@ -89,7 +89,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
<< " " << STRING_CMD_DIAG_VERSION << ": "
|
<< " " << STRING_CMD_DIAG_VERSION << ": "
|
||||||
<< __VERSION__ << '\n'
|
<< __VERSION__ << '\n'
|
||||||
#endif
|
#endif
|
||||||
<< " " << STRING_CMD_DIAG_CAPS << ":"
|
<< " " << STRING_CMD_DIAG_CAPS << ':'
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
<< " +stdc"
|
<< " +stdc"
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,7 +168,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
#ifdef CMAKE_BUILD_TYPE
|
#ifdef CMAKE_BUILD_TYPE
|
||||||
<< CMAKE_BUILD_TYPE
|
<< CMAKE_BUILD_TYPE
|
||||||
#else
|
#else
|
||||||
<< "-"
|
<< '-'
|
||||||
#endif
|
#endif
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
auto last_slash = credentials.rfind ('/');
|
auto last_slash = credentials.rfind ('/');
|
||||||
if (last_slash != std::string::npos)
|
if (last_slash != std::string::npos)
|
||||||
credentials = credentials.substr (0, last_slash)
|
credentials = credentials.substr (0, last_slash)
|
||||||
+ "/"
|
+ '/'
|
||||||
+ std::string (credentials.length () - last_slash - 1, '*');
|
+ std::string (credentials.length () - last_slash - 1, '*');
|
||||||
|
|
||||||
out << " Creds: "
|
out << " Creds: "
|
||||||
|
@ -379,7 +379,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
<< (term ? term : STRING_CMD_DIAG_NONE)
|
<< (term ? term : STRING_CMD_DIAG_NONE)
|
||||||
<< " ("
|
<< " ("
|
||||||
<< context.getWidth ()
|
<< context.getWidth ()
|
||||||
<< "x"
|
<< 'x'
|
||||||
<< context.getHeight ()
|
<< context.getHeight ()
|
||||||
<< ")\n";
|
<< ")\n";
|
||||||
|
|
||||||
|
|
|
@ -798,7 +798,7 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
|
||||||
|
|
||||||
// Complete the command line.
|
// Complete the command line.
|
||||||
editor += ' ';
|
editor += ' ';
|
||||||
editor += "\"" + file.str () + "\"";
|
editor += '"' + file.str () + '"';
|
||||||
|
|
||||||
ARE_THESE_REALLY_HARMFUL:
|
ARE_THESE_REALLY_HARMFUL:
|
||||||
bool changes = false; // No changes made.
|
bool changes = false; // No changes made.
|
||||||
|
|
|
@ -84,7 +84,7 @@ int CmdExport::execute (std::string& output)
|
||||||
if (counter)
|
if (counter)
|
||||||
{
|
{
|
||||||
if (json_array)
|
if (json_array)
|
||||||
output += ",";
|
output += ',';
|
||||||
output += '\n';
|
output += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -525,9 +525,9 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
|
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
|
||||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
|
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
|
||||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
|
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
|
||||||
|
|
||||||
bar += std::string (leftOffset - aBar.length (), ' ');
|
bar += std::string (leftOffset - aBar.length (), ' ');
|
||||||
bar += aBar + cBar + dBar;
|
bar += aBar + cBar + dBar;
|
||||||
|
@ -722,9 +722,9 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string aBar = ""; while (aBar.length () < addedBar) aBar += "+";
|
std::string aBar = ""; while (aBar.length () < addedBar) aBar += '+';
|
||||||
std::string cBar = ""; while (cBar.length () < completedBar) cBar += "X";
|
std::string cBar = ""; while (cBar.length () < completedBar) cBar += 'X';
|
||||||
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += "-";
|
std::string dBar = ""; while (dBar.length () < deletedBar) dBar += '-';
|
||||||
|
|
||||||
bar += std::string (leftOffset - aBar.length (), ' ');
|
bar += std::string (leftOffset - aBar.length (), ' ');
|
||||||
bar += aBar + cBar + dBar;
|
bar += aBar + cBar + dBar;
|
||||||
|
|
|
@ -103,7 +103,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
|
||||||
result << ' ';
|
result << ' ';
|
||||||
|
|
||||||
if (range_start < range_end)
|
if (range_start < range_end)
|
||||||
result << ids[range_start] << "-" << ids[range_end];
|
result << ids[range_start] << '-' << ids[range_end];
|
||||||
else
|
else
|
||||||
result << ids[range_start];
|
result << ids[range_start];
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ std::string CmdIDs::compressIds (const std::vector <int>& ids)
|
||||||
result << ' ';
|
result << ' ';
|
||||||
|
|
||||||
if (range_start < range_end)
|
if (range_start < range_end)
|
||||||
result << ids[range_start] << "-" << ids[range_end];
|
result << ids[range_start] << '-' << ids[range_end];
|
||||||
else
|
else
|
||||||
result << ids[range_start];
|
result << ids[range_start];
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ int CmdZshCompletionUuids::execute (std::string& output)
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (auto& task : filtered)
|
for (auto& task : filtered)
|
||||||
out << task.get ("uuid")
|
out << task.get ("uuid")
|
||||||
<< ":"
|
<< ':'
|
||||||
<< str_replace (task.get ("description"), ":", zshColonReplacement)
|
<< str_replace (task.get ("description"), ":", zshColonReplacement)
|
||||||
<< '\n';
|
<< '\n';
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
age = ISO8601p (now - dt).formatVague ();
|
age = ISO8601p (now - dt).formatVague ();
|
||||||
}
|
}
|
||||||
|
|
||||||
view.set (row, 1, entry + " (" + age + ")");
|
view.set (row, 1, entry + " (" + age + ')');
|
||||||
|
|
||||||
// wait
|
// wait
|
||||||
if (task.has ("wait"))
|
if (task.has ("wait"))
|
||||||
|
@ -289,7 +289,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
|
|
||||||
ISO8601d mod (task.get_date ("modified"));
|
ISO8601d mod (task.get_date ("modified"));
|
||||||
std::string age = ISO8601p (now - mod).formatVague ();
|
std::string age = ISO8601p (now - mod).formatVague ();
|
||||||
view.set (row, 1, mod.toString (dateformat) + " (" + age + ")");
|
view.set (row, 1, mod.toString (dateformat) + " (" + age + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
// tags ...
|
// tags ...
|
||||||
|
@ -399,8 +399,8 @@ int CmdInfo::execute (std::string& output)
|
||||||
context.columns.find (att) == context.columns.end ())
|
context.columns.find (att) == context.columns.end ())
|
||||||
{
|
{
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
view.set (row, 0, "[" + att);
|
view.set (row, 0, '[' + att);
|
||||||
view.set (row, 1, task.get (att) + "]");
|
view.set (row, 1, task.get (att) + ']');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ int CmdStats::execute (std::string& output)
|
||||||
view.set (row, 0, STRING_CMD_STATS_TAGGED);
|
view.set (row, 0, STRING_CMD_STATS_TAGGED);
|
||||||
|
|
||||||
std::stringstream value;
|
std::stringstream value;
|
||||||
value << std::setprecision (3) << (100.0 * taggedT / totalT) << "%";
|
value << std::setprecision (3) << (100.0 * taggedT / totalT) << '%';
|
||||||
view.set (row, 1, value.str ());
|
view.set (row, 1, value.str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ static void colorizeKeyword (Task& task, const std::string& rule, const Color& b
|
||||||
static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c, bool merge)
|
static void colorizeUDA (Task& task, const std::string& rule, const Color& base, Color& c, bool merge)
|
||||||
{
|
{
|
||||||
// Is the rule color.uda.name.value or color.uda.name?
|
// Is the rule color.uda.name.value or color.uda.name?
|
||||||
auto pos = rule.find (".", 10);
|
auto pos = rule.find ('.', 10);
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
{
|
{
|
||||||
if (task.has (rule.substr (10)))
|
if (task.has (rule.substr (10)))
|
||||||
|
|
|
@ -283,7 +283,7 @@ bool extractLine (
|
||||||
// No backtrack, possible hyphenation.
|
// No backtrack, possible hyphenation.
|
||||||
else if (hyphenate)
|
else if (hyphenate)
|
||||||
{
|
{
|
||||||
line = text.substr (offset, prior_cursor - offset) + "-";
|
line = text.substr (offset, prior_cursor - offset) + '-';
|
||||||
offset = prior_cursor;
|
offset = prior_cursor;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ template<typename T>
|
||||||
const std::string format (int fmt_num, const std::string& fmt, T arg)
|
const std::string format (int fmt_num, const std::string& fmt, T arg)
|
||||||
{
|
{
|
||||||
std::string output = fmt;
|
std::string output = fmt;
|
||||||
replace_positional (output, "{" + format (fmt_num) + "}", format (arg));
|
replace_positional (output, '{' + format (fmt_num) + '}', format (arg));
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
src/util.cpp
12
src/util.cpp
|
@ -64,7 +64,7 @@ static void signal_handler (int s)
|
||||||
{
|
{
|
||||||
if (s == SIGINT)
|
if (s == SIGINT)
|
||||||
{
|
{
|
||||||
std::cout << "\n\n" << STRING_ERROR_CONFIRM_SIGINT << "\n";
|
std::cout << "\n\n" << STRING_ERROR_CONFIRM_SIGINT << '\n';
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ bool confirm (const std::string& question)
|
||||||
|
|
||||||
std::string answer {""};
|
std::string answer {""};
|
||||||
std::getline (std::cin, answer);
|
std::getline (std::cin, answer);
|
||||||
context.debug ("STDIN '" + answer + "'");
|
context.debug ("STDIN '" + answer + '\'');
|
||||||
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_NO : Lexer::lowerCase (Lexer::trim (answer));
|
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_NO : Lexer::lowerCase (Lexer::trim (answer));
|
||||||
|
|
||||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
||||||
|
@ -121,15 +121,15 @@ int confirm4 (const std::string& question)
|
||||||
{
|
{
|
||||||
std::cout << question
|
std::cout << question
|
||||||
<< " ("
|
<< " ("
|
||||||
<< options[1] << "/"
|
<< options[1] << '/'
|
||||||
<< options[2] << "/"
|
<< options[2] << '/'
|
||||||
<< options[4] << "/"
|
<< options[4] << '/'
|
||||||
<< options[5]
|
<< options[5]
|
||||||
<< ") ";
|
<< ") ";
|
||||||
|
|
||||||
std::string answer {""};
|
std::string answer {""};
|
||||||
std::getline (std::cin, answer);
|
std::getline (std::cin, answer);
|
||||||
context.debug ("STDIN '" + answer + "'");
|
context.debug ("STDIN '" + answer + '\'');
|
||||||
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_QUIT : Lexer::lowerCase (Lexer::trim (answer));
|
answer = std::cin.eof () ? STRING_UTIL_CONFIRM_QUIT : Lexer::lowerCase (Lexer::trim (answer));
|
||||||
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
autoComplete (answer, options, matches, 1); // Hard-coded 1.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue