Portability: Updated to make main re-entrant()
- New INSTALL instructions to emscripten, and AUTHORS for contribution.
This commit is contained in:
committed by
Paul Beckingham
parent
cae3f06b7d
commit
7af6db4c17
@@ -30,8 +30,6 @@
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAdd::CmdAdd ()
|
||||
{
|
||||
@@ -54,7 +52,7 @@ int CmdAdd::execute (std::string& output)
|
||||
// Apply the command line modifications to the new task.
|
||||
Task task;
|
||||
task.modify (Task::modReplace, true);
|
||||
context.tdb2.add (task);
|
||||
Context::getContext ().tdb2.add (task);
|
||||
|
||||
// Do not display ID 0, users cannot query by that
|
||||
auto status = task.getStatus ();
|
||||
@@ -64,25 +62,25 @@ int CmdAdd::execute (std::string& output)
|
||||
// it's enduring and never changes, and it's unlikely the caller
|
||||
// asked for this if they just wanted a human-friendly number.
|
||||
|
||||
if (context.verbose ("new-uuid") &&
|
||||
if (Context::getContext ().verbose ("new-uuid") &&
|
||||
status != Task::recurring)
|
||||
output += format ("Created task {1}.\n", task.get ("uuid"));
|
||||
|
||||
else if (context.verbose ("new-uuid") &&
|
||||
else if (Context::getContext ().verbose ("new-uuid") &&
|
||||
status == Task::recurring)
|
||||
output += format ("Created task {1} (recurrence template).\n", task.get ("uuid"));
|
||||
|
||||
else if (context.verbose ("new-id") &&
|
||||
else if (Context::getContext ().verbose ("new-id") &&
|
||||
(status == Task::pending ||
|
||||
status == Task::waiting))
|
||||
output += format ("Created task {1}.\n", task.id);
|
||||
|
||||
else if (context.verbose ("new-id") &&
|
||||
else if (Context::getContext ().verbose ("new-id") &&
|
||||
status == Task::recurring)
|
||||
output += format ("Created task {1} (recurrence template).\n", task.id);
|
||||
|
||||
if (context.verbose ("project"))
|
||||
context.footnote (onProjectChange (task));
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
Context::getContext ().footnote (onProjectChange (task));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <Context.h>
|
||||
#include <Command.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdCompletionAliases::CmdCompletionAliases ()
|
||||
{
|
||||
@@ -50,7 +48,7 @@ CmdCompletionAliases::CmdCompletionAliases ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdCompletionAliases::execute (std::string& output)
|
||||
{
|
||||
for (const auto& alias : context.config)
|
||||
for (const auto& alias : Context::getContext ().config)
|
||||
if (alias.first.substr (0, 6) == "alias.")
|
||||
output += alias.first.substr (6) + '\n';
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAnnotate::CmdAnnotate ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdAnnotate::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -85,33 +83,33 @@ int CmdAnnotate::execute (std::string&)
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Annotating task {1} '{2}'.", task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
|
||||
// Annotate siblings.
|
||||
if (task.has ("parent"))
|
||||
{
|
||||
if ((context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if ((Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm ("This is a recurring task. Do you want to annotate all pending recurrences of this same task?")) ||
|
||||
context.config.getBoolean ("recurrence.confirmation"))
|
||||
Context::getContext ().config.getBoolean ("recurrence.confirmation"))
|
||||
{
|
||||
auto siblings = context.tdb2.siblings (task);
|
||||
auto siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
sibling.modify (Task::modAnnotate, true);
|
||||
context.tdb2.modify (sibling);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
feedback_affected ("Annotating recurring task {1} '{2}'.", sibling);
|
||||
}
|
||||
|
||||
// Annotate the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task.get ("parent"), parent);
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
parent.modify (Task::modAnnotate, true);
|
||||
context.tdb2.modify (parent);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +125,7 @@ int CmdAnnotate::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Annotated {1} task." : "Annotated {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdAppend::CmdAppend ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdAppend::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -85,33 +83,33 @@ int CmdAppend::execute (std::string&)
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Appending to task {1} '{2}'.", task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
|
||||
// Append to siblings.
|
||||
if (task.has ("parent"))
|
||||
{
|
||||
if ((context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if ((Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm ("This is a recurring task. Do you want to append to all pending recurrences of this same task?")) ||
|
||||
context.config.getBoolean ("recurrence.confirmation"))
|
||||
Context::getContext ().config.getBoolean ("recurrence.confirmation"))
|
||||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (task);
|
||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
sibling.modify (Task::modAppend, true);
|
||||
context.tdb2.modify (sibling);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
feedback_affected ("Appending to recurring task {1} '{2}'.", sibling);
|
||||
}
|
||||
|
||||
// Append to the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task.get ("parent"), parent);
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
parent.modify (Task::modAppend, true);
|
||||
context.tdb2.modify (parent);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +125,7 @@ int CmdAppend::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Appended {1} task." : "Appended {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#include <Context.h>
|
||||
#include <Command.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdZshAttributes::CmdZshAttributes ()
|
||||
{
|
||||
@@ -53,7 +51,7 @@ CmdZshAttributes::CmdZshAttributes ()
|
||||
int CmdZshAttributes::execute (std::string& output)
|
||||
{
|
||||
// Get a list of all columns, sort them.
|
||||
auto columns = context.getColumns ();
|
||||
auto columns = Context::getContext ().getColumns ();
|
||||
std::sort (columns.begin (), columns.end ());
|
||||
|
||||
std::stringstream out;
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
// Helper macro.
|
||||
#define LOC(y,x) (((y) * (_width + 1)) + (x))
|
||||
|
||||
@@ -174,8 +172,8 @@ Chart::Chart (char type)
|
||||
{
|
||||
// How much space is there to render in? This chart will occupy the
|
||||
// maximum space, and the width drives various other parameters.
|
||||
_width = context.getWidth ();
|
||||
_height = context.getHeight () - 1; // Allow for new line with prompt.
|
||||
_width = Context::getContext ().getWidth ();
|
||||
_height = Context::getContext ().getHeight () - 1; // Allow for new line with prompt.
|
||||
_max_value = 0;
|
||||
_max_label = 1;
|
||||
_graph_height = _height - 7;
|
||||
@@ -193,7 +191,7 @@ Chart::Chart (char type)
|
||||
_net_fix_rate = 0.0;
|
||||
|
||||
// Set the title.
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::vector <std::string> words = Context::getContext ().cli2.getWords ();
|
||||
auto filter = join (" ", words);
|
||||
_title = '(' + filter + ')';
|
||||
}
|
||||
@@ -396,7 +394,7 @@ std::string Chart::render ()
|
||||
}
|
||||
|
||||
if (_max_value == 0)
|
||||
context.footnote ("No matches.");
|
||||
Context::getContext ().footnote ("No matches.");
|
||||
|
||||
// Create a grid, folded into a string.
|
||||
_grid = "";
|
||||
@@ -520,12 +518,12 @@ std::string Chart::render ()
|
||||
|
||||
optimizeGrid ();
|
||||
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
// Colorize the grid.
|
||||
Color color_pending (context.config.get ("color.burndown.pending"));
|
||||
Color color_done (context.config.get ("color.burndown.done"));
|
||||
Color color_started (context.config.get ("color.burndown.started"));
|
||||
Color color_pending (Context::getContext ().config.get ("color.burndown.pending"));
|
||||
Color color_done (Context::getContext ().config.get ("color.burndown.done"));
|
||||
Color color_started (Context::getContext ().config.get ("color.burndown.started"));
|
||||
|
||||
// Replace DD, SS, PP with colored strings.
|
||||
std::string::size_type i;
|
||||
@@ -799,7 +797,7 @@ void Chart::calculateRates ()
|
||||
<< ", with currently "
|
||||
<< _current_count
|
||||
<< " pending tasks";
|
||||
context.debug (peak_message.str ());
|
||||
Context::getContext ().debug (peak_message.str ());
|
||||
|
||||
// If there are no current pending tasks, then it is meaningless to find
|
||||
// rates or estimated completion date.
|
||||
@@ -824,16 +822,16 @@ void Chart::calculateRates ()
|
||||
<< " = "
|
||||
<< _net_fix_rate
|
||||
<< " tasks/d";
|
||||
context.debug (rate_message.str ());
|
||||
Context::getContext ().debug (rate_message.str ());
|
||||
|
||||
Duration delta (static_cast <time_t> (_current_count / fix_rate));
|
||||
Datetime end = now + delta.toTime_t ();
|
||||
|
||||
// Prefer dateformat.report over dateformat.
|
||||
std::string format = context.config.get ("dateformat.report");
|
||||
std::string format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
{
|
||||
format = context.config.get ("dateformat");
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
if (format == "")
|
||||
format = "Y-M-D";
|
||||
}
|
||||
@@ -852,7 +850,7 @@ void Chart::calculateRates ()
|
||||
<< delta.format ()
|
||||
<< " --> "
|
||||
<< end.toISO ();
|
||||
context.debug (completion_message.str ());
|
||||
Context::getContext ().debug (completion_message.str ());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <Filter.h>
|
||||
#include <Eval.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdCalc::CmdCalc ()
|
||||
{
|
||||
@@ -52,17 +50,17 @@ int CmdCalc::execute (std::string& output)
|
||||
{
|
||||
// Configurable infix/postfix
|
||||
bool infix {true};
|
||||
if (context.config.get ("expressions") == "postfix")
|
||||
if (Context::getContext ().config.get ("expressions") == "postfix")
|
||||
infix = false;
|
||||
|
||||
// Create an evaluator with DOM access.
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
e.debug (context.config.getBoolean ("debug"));
|
||||
e.debug (Context::getContext ().config.getBoolean ("debug"));
|
||||
|
||||
// Compile all the args into one expression.
|
||||
std::string expression;
|
||||
for (const auto& word : context.cli2.getWords ())
|
||||
for (const auto& word : Context::getContext ().cli2.getWords ())
|
||||
expression += word + ' ';
|
||||
|
||||
// Evaluate according to preference.
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdCalendar::CmdCalendar ()
|
||||
{
|
||||
@@ -63,8 +61,8 @@ int CmdCalendar::execute (std::string& output)
|
||||
|
||||
// Each month requires 28 text columns width. See how many will actually
|
||||
// fit. But if a preference is specified, and it fits, use it.
|
||||
auto width = context.getWidth ();
|
||||
auto preferredMonthsPerLine = context.config.getInteger ("monthsperline");
|
||||
auto width = Context::getContext ().getWidth ();
|
||||
auto preferredMonthsPerLine = Context::getContext ().config.getInteger ("monthsperline");
|
||||
auto monthsThatFit = width / 26;
|
||||
|
||||
auto monthsPerLine = monthsThatFit;
|
||||
@@ -74,7 +72,7 @@ int CmdCalendar::execute (std::string& output)
|
||||
// Load the pending tasks.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
auto tasks = context.tdb2.pending.get_tasks ();
|
||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
Datetime today;
|
||||
auto getPendingDate = false;
|
||||
@@ -108,14 +106,14 @@ int CmdCalendar::execute (std::string& output)
|
||||
auto argYear = 0;
|
||||
auto argWholeYear = false;
|
||||
|
||||
for (auto& arg : context.cli2.getWords ())
|
||||
for (auto& arg : Context::getContext ().cli2.getWords ())
|
||||
{
|
||||
// Some version of "calendar".
|
||||
if (autoComplete (Lexer::lowerCase (arg), commandNames, matches, context.config.getInteger ("abbreviation.minimum")) == 1)
|
||||
if (autoComplete (Lexer::lowerCase (arg), commandNames, matches, Context::getContext ().config.getInteger ("abbreviation.minimum")) == 1)
|
||||
continue;
|
||||
|
||||
// "due".
|
||||
else if (autoComplete (Lexer::lowerCase (arg), keywordNames, matches, context.config.getInteger ("abbreviation.minimum")) == 1)
|
||||
else if (autoComplete (Lexer::lowerCase (arg), keywordNames, matches, Context::getContext ().config.getInteger ("abbreviation.minimum")) == 1)
|
||||
getPendingDate = true;
|
||||
|
||||
// "y".
|
||||
@@ -135,7 +133,7 @@ int CmdCalendar::execute (std::string& output)
|
||||
}
|
||||
|
||||
// "January" etc.
|
||||
else if (autoComplete (Lexer::lowerCase (arg), monthNames, matches, context.config.getInteger ("abbreviation.minimum")) == 1)
|
||||
else if (autoComplete (Lexer::lowerCase (arg), monthNames, matches, Context::getContext ().config.getInteger ("abbreviation.minimum")) == 1)
|
||||
{
|
||||
argMonth = Datetime::monthOfYear (matches[0]);
|
||||
if (argMonth == -1)
|
||||
@@ -192,10 +190,10 @@ int CmdCalendar::execute (std::string& output)
|
||||
yFrom = oldest.year();
|
||||
}
|
||||
|
||||
if (context.config.getBoolean ("calendar.offset"))
|
||||
if (Context::getContext ().config.getBoolean ("calendar.offset"))
|
||||
{
|
||||
auto moffset = context.config.getInteger ("calendar.offset.value") % 12;
|
||||
auto yoffset = context.config.getInteger ("calendar.offset.value") / 12;
|
||||
auto moffset = Context::getContext ().config.getInteger ("calendar.offset.value") % 12;
|
||||
auto yoffset = Context::getContext ().config.getInteger ("calendar.offset.value") / 12;
|
||||
mFrom += moffset;
|
||||
yFrom += yoffset;
|
||||
if (mFrom < 1)
|
||||
@@ -279,15 +277,15 @@ int CmdCalendar::execute (std::string& output)
|
||||
}
|
||||
}
|
||||
|
||||
Color color_today (context.config.get ("color.calendar.today"));
|
||||
Color color_due (context.config.get ("color.calendar.due"));
|
||||
Color color_duetoday (context.config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (context.config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (context.config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (context.config.get ("color.calendar.holiday"));
|
||||
Color color_weeknumber (context.config.get ("color.calendar.weeknumber"));
|
||||
Color color_today (Context::getContext ().config.get ("color.calendar.today"));
|
||||
Color color_due (Context::getContext ().config.get ("color.calendar.due"));
|
||||
Color color_duetoday (Context::getContext ().config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (Context::getContext ().config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (Context::getContext ().config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (Context::getContext ().config.get ("color.calendar.holiday"));
|
||||
Color color_weeknumber (Context::getContext ().config.get ("color.calendar.weeknumber"));
|
||||
|
||||
if (context.color () && context.config.getBoolean ("calendar.legend"))
|
||||
if (Context::getContext ().color () && Context::getContext ().config.getBoolean ("calendar.legend"))
|
||||
out << "Legend: "
|
||||
<< color_today.colorize ("today")
|
||||
<< ", "
|
||||
@@ -306,7 +304,7 @@ int CmdCalendar::execute (std::string& output)
|
||||
<< optionalBlankLine ()
|
||||
<< '\n';
|
||||
|
||||
if (context.config.get ("calendar.details") == "full" || context.config.get ("calendar.holidays") == "full")
|
||||
if (Context::getContext ().config.get ("calendar.details") == "full" || Context::getContext ().config.get ("calendar.holidays") == "full")
|
||||
{
|
||||
--details_mFrom;
|
||||
if (details_mFrom == 0)
|
||||
@@ -324,30 +322,30 @@ int CmdCalendar::execute (std::string& output)
|
||||
}
|
||||
|
||||
Datetime date_after (details_yFrom, details_mFrom, details_dFrom);
|
||||
auto after = date_after.toString (context.config.get ("dateformat"));
|
||||
auto after = date_after.toString (Context::getContext ().config.get ("dateformat"));
|
||||
|
||||
Datetime date_before (yTo, mTo, 1);
|
||||
auto before = date_before.toString (context.config.get ("dateformat"));
|
||||
auto before = date_before.toString (Context::getContext ().config.get ("dateformat"));
|
||||
|
||||
// Table with due date information
|
||||
if (context.config.get ("calendar.details") == "full")
|
||||
if (Context::getContext ().config.get ("calendar.details") == "full")
|
||||
{
|
||||
// Assert that 'report' is a valid report.
|
||||
auto report = context.config.get ("calendar.details.report");
|
||||
if (context.commands.find (report) == context.commands.end ())
|
||||
auto report = Context::getContext ().config.get ("calendar.details.report");
|
||||
if (Context::getContext ().commands.find (report) == Context::getContext ().commands.end ())
|
||||
throw std::string ("The setting 'calendar.details.report' must contain a single report name.");
|
||||
|
||||
// TODO Fix this: cal --> task
|
||||
// calendar --> taskendar
|
||||
|
||||
// If the executable was "cal" or equivalent, replace it with "task".
|
||||
auto executable = context.cli2._original_args[0].attribute ("raw");
|
||||
auto executable = Context::getContext ().cli2._original_args[0].attribute ("raw");
|
||||
auto cal = executable.find ("cal");
|
||||
if (cal != std::string::npos)
|
||||
executable = executable.substr (0, cal) + PACKAGE;
|
||||
|
||||
std::vector <std::string> args;
|
||||
args.push_back ("rc:" + context.rc_file._data);
|
||||
args.push_back ("rc:" + Context::getContext ().rc_file._data);
|
||||
args.push_back ("rc.due:0");
|
||||
args.push_back ("rc.verbose:label,affected,blank");
|
||||
args.push_back ("due.after:" + after);
|
||||
@@ -361,34 +359,34 @@ int CmdCalendar::execute (std::string& output)
|
||||
}
|
||||
|
||||
// Table with holiday information
|
||||
if (context.config.get ("calendar.holidays") == "full")
|
||||
if (Context::getContext ().config.get ("calendar.holidays") == "full")
|
||||
{
|
||||
Table holTable;
|
||||
holTable.width (context.getWidth ());
|
||||
holTable.width (Context::getContext ().getWidth ());
|
||||
holTable.add ("Date");
|
||||
holTable.add ("Holiday");
|
||||
setHeaderUnderline (holTable);
|
||||
|
||||
std::map <time_t, std::vector<std::string>> hm; // we need to store multiple holidays per day
|
||||
for (auto& it : context.config)
|
||||
for (auto& it : Context::getContext ().config)
|
||||
if (it.first.substr (0, 8) == "holiday.")
|
||||
if (it.first.substr (it.first.size () - 4) == "name")
|
||||
{
|
||||
auto holName = context.config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".name");
|
||||
auto holDate = context.config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".date");
|
||||
Datetime hDate (holDate.c_str (), context.config.get ("dateformat.holiday"));
|
||||
auto holName = Context::getContext ().config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".name");
|
||||
auto holDate = Context::getContext ().config.get ("holiday." + it.first.substr (8, it.first.size () - 13) + ".date");
|
||||
Datetime hDate (holDate.c_str (), Context::getContext ().config.get ("dateformat.holiday"));
|
||||
|
||||
if (date_after < hDate && hDate < date_before)
|
||||
hm[hDate.toEpoch()].push_back (holName);
|
||||
}
|
||||
|
||||
auto format = context.config.get ("report." +
|
||||
context.config.get ("calendar.details.report") +
|
||||
auto format = Context::getContext ().config.get ("report." +
|
||||
Context::getContext ().config.get ("calendar.details.report") +
|
||||
".dateformat");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat.report");
|
||||
format = Context::getContext ().config.get ("dateformat.report");
|
||||
if (format == "")
|
||||
format = context.config.get ("dateformat");
|
||||
format = Context::getContext ().config.get ("dateformat");
|
||||
|
||||
for (auto& hm_it : hm)
|
||||
{
|
||||
@@ -422,14 +420,14 @@ std::string CmdCalendar::renderMonths (
|
||||
int monthsPerLine)
|
||||
{
|
||||
// What day of the week does the user consider the first?
|
||||
auto weekStart = Datetime::dayOfWeek (context.config.get ("weekstart"));
|
||||
auto weekStart = Datetime::dayOfWeek (Context::getContext ().config.get ("weekstart"));
|
||||
if (weekStart != 0 && weekStart != 1)
|
||||
throw std::string ("The 'weekstart' configuration variable may only contain 'Sunday' or 'Monday'.");
|
||||
|
||||
// Build table for the number of months to be displayed.
|
||||
Table view;
|
||||
setHeaderUnderline (view);
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
for (int i = 0 ; i < (monthsPerLine * 8); i += 8)
|
||||
{
|
||||
if (weekStart == 1)
|
||||
@@ -487,13 +485,13 @@ std::string CmdCalendar::renderMonths (
|
||||
|
||||
auto row = 0;
|
||||
|
||||
Color color_today (context.config.get ("color.calendar.today"));
|
||||
Color color_due (context.config.get ("color.calendar.due"));
|
||||
Color color_duetoday (context.config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (context.config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (context.config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (context.config.get ("color.calendar.holiday"));
|
||||
Color color_weeknumber (context.config.get ("color.calendar.weeknumber"));
|
||||
Color color_today (Context::getContext ().config.get ("color.calendar.today"));
|
||||
Color color_due (Context::getContext ().config.get ("color.calendar.due"));
|
||||
Color color_duetoday (Context::getContext ().config.get ("color.calendar.due.today"));
|
||||
Color color_overdue (Context::getContext ().config.get ("color.calendar.overdue"));
|
||||
Color color_weekend (Context::getContext ().config.get ("color.calendar.weekend"));
|
||||
Color color_holiday (Context::getContext ().config.get ("color.calendar.holiday"));
|
||||
Color color_weeknumber (Context::getContext ().config.get ("color.calendar.weeknumber"));
|
||||
|
||||
// Loop through months to be added on this line.
|
||||
for (int mpl = 0; mpl < monthsPerLine ; mpl++)
|
||||
@@ -509,7 +507,7 @@ std::string CmdCalendar::renderMonths (
|
||||
auto dow = temp.dayOfWeek ();
|
||||
auto woy = temp.week ();
|
||||
|
||||
if (context.config.getBoolean ("displayweeknumber"))
|
||||
if (Context::getContext ().config.getBoolean ("displayweeknumber"))
|
||||
view.set (row,
|
||||
(8 * mpl),
|
||||
// Make sure the week number is always 4 columns, space-padded.
|
||||
@@ -526,7 +524,7 @@ std::string CmdCalendar::renderMonths (
|
||||
|
||||
view.set (row, thisCol, d);
|
||||
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
Color cellColor;
|
||||
|
||||
@@ -535,14 +533,14 @@ std::string CmdCalendar::renderMonths (
|
||||
cellColor.blend (color_weekend);
|
||||
|
||||
// colorize holidays
|
||||
if (context.config.get ("calendar.holidays") != "none")
|
||||
if (Context::getContext ().config.get ("calendar.holidays") != "none")
|
||||
{
|
||||
for (auto& hol : context.config)
|
||||
for (auto& hol : Context::getContext ().config)
|
||||
if (hol.first.substr (0, 8) == "holiday.")
|
||||
if (hol.first.substr (hol.first.size () - 4) == "date")
|
||||
{
|
||||
std::string value = hol.second;
|
||||
Datetime holDate (value.c_str (), context.config.get ("dateformat.holiday"));
|
||||
Datetime holDate (value.c_str (), Context::getContext ().config.get ("dateformat.holiday"));
|
||||
if (holDate.day () == d &&
|
||||
holDate.month () == months[mpl] &&
|
||||
holDate.year () == years[mpl])
|
||||
@@ -557,9 +555,9 @@ std::string CmdCalendar::renderMonths (
|
||||
cellColor.blend (color_today);
|
||||
|
||||
// colorize due tasks
|
||||
if (context.config.get ("calendar.details") != "none")
|
||||
if (Context::getContext ().config.get ("calendar.details") != "none")
|
||||
{
|
||||
context.config.set ("due", 0);
|
||||
Context::getContext ().config.set ("due", 0);
|
||||
for (auto& task : all)
|
||||
{
|
||||
if (task.getStatus () == Task::pending &&
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdColor::CmdColor ()
|
||||
{
|
||||
@@ -59,13 +57,13 @@ int CmdColor::execute (std::string& output)
|
||||
|
||||
// Get the non-attribute, non-fancy command line arguments.
|
||||
auto legend = false;
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
for (auto& word : words)
|
||||
if (closeEnough ("legend", word))
|
||||
legend = true;
|
||||
|
||||
std::stringstream out;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
// If the description contains 'legend', show all the colors currently in
|
||||
// use.
|
||||
@@ -74,13 +72,13 @@ int CmdColor::execute (std::string& output)
|
||||
out << "\nHere are the colors currently in use:\n";
|
||||
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
if (context.config.getBoolean ("color"))
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
if (Context::getContext ().config.getBoolean ("color"))
|
||||
view.forceColor ();
|
||||
view.add ("Color");
|
||||
view.add ("Definition");
|
||||
|
||||
for (auto& item : context.config)
|
||||
for (auto& item : Context::getContext ().config)
|
||||
{
|
||||
// Skip items with 'color' in their name, that are not referring to
|
||||
// actual colors.
|
||||
@@ -88,7 +86,7 @@ int CmdColor::execute (std::string& output)
|
||||
item.first != "color" &&
|
||||
item.first.find ("color") == 0)
|
||||
{
|
||||
Color color (context.config.get (item.first));
|
||||
Color color (Context::getContext ().config.get (item.first));
|
||||
int row = view.addRow ();
|
||||
view.set (row, 0, item.first, color);
|
||||
view.set (row, 1, item.second, color);
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdColumns::CmdColumns ()
|
||||
{
|
||||
@@ -57,20 +55,20 @@ int CmdColumns::execute (std::string& output)
|
||||
{
|
||||
// Obtain the arguments from the description. That way, things like '--'
|
||||
// have already been handled.
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () > 1)
|
||||
throw std::string ("You can only specify one search string.");
|
||||
|
||||
// Include all columns in the table.
|
||||
std::vector <std::string> names;
|
||||
for (const auto& col : context.columns)
|
||||
for (const auto& col : Context::getContext ().columns)
|
||||
names.push_back (col.first);
|
||||
|
||||
std::sort (names.begin (), names.end ());
|
||||
|
||||
// Render a list of column names, formats and examples.
|
||||
Table formats;
|
||||
formats.width (context.getWidth ());
|
||||
formats.width (Context::getContext ().getWidth ());
|
||||
formats.add ("Columns");
|
||||
formats.add ("Type");
|
||||
formats.add ("Modifiable");
|
||||
@@ -83,15 +81,15 @@ int CmdColumns::execute (std::string& output)
|
||||
if (words.size () == 0 ||
|
||||
find (name, words[0], false) != std::string::npos)
|
||||
{
|
||||
auto styles = context.columns[name]->styles ();
|
||||
auto examples = context.columns[name]->examples ();
|
||||
auto styles = Context::getContext ().columns[name]->styles ();
|
||||
auto examples = Context::getContext ().columns[name]->examples ();
|
||||
|
||||
for (unsigned int i = 0; i < styles.size (); ++i)
|
||||
{
|
||||
auto row = formats.addRow ();
|
||||
formats.set (row, 0, i == 0 ? name : "");
|
||||
formats.set (row, 1, i == 0 ? context.columns[name]->type () : "");
|
||||
formats.set (row, 2, i == 0 ? (context.columns[name]->modifiable () ? "Modifiable" : "Read Only") : "");
|
||||
formats.set (row, 1, i == 0 ? Context::getContext ().columns[name]->type () : "");
|
||||
formats.set (row, 2, i == 0 ? (Context::getContext ().columns[name]->modifiable () ? "Modifiable" : "Read Only") : "");
|
||||
formats.set (row, 3, styles[i] + (i == 0 ? "*" : ""));
|
||||
formats.set (row, 4, i < examples.size () ? examples[i] : "");
|
||||
}
|
||||
@@ -137,7 +135,7 @@ int CmdCompletionColumns::execute (std::string& output)
|
||||
{
|
||||
// Include all columns.
|
||||
std::vector <std::string> names;
|
||||
for (const auto& col : context.columns)
|
||||
for (const auto& col : Context::getContext ().columns)
|
||||
names.push_back (col.first);
|
||||
|
||||
std::sort (names.begin (), names.end ());
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <Command.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdCommands::CmdCommands ()
|
||||
{
|
||||
@@ -56,7 +54,7 @@ CmdCommands::CmdCommands ()
|
||||
int CmdCommands::execute (std::string& output)
|
||||
{
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("Command");
|
||||
view.add ("Category");
|
||||
view.add ("R/W", false);
|
||||
@@ -67,12 +65,12 @@ int CmdCommands::execute (std::string& output)
|
||||
view.add ("Mods", false);
|
||||
view.add ("Misc", false);
|
||||
view.add ("Description");
|
||||
view.leftMargin (context.config.getInteger ("indent.report"));
|
||||
view.extraPadding (context.config.getInteger ("row.padding"));
|
||||
view.intraPadding (context.config.getInteger ("column.padding"));
|
||||
view.leftMargin (Context::getContext ().config.getInteger ("indent.report"));
|
||||
view.extraPadding (Context::getContext ().config.getInteger ("row.padding"));
|
||||
view.intraPadding (Context::getContext ().config.getInteger ("column.padding"));
|
||||
setHeaderUnderline (view);
|
||||
|
||||
for (auto& command : context.commands)
|
||||
for (auto& command : Context::getContext ().commands)
|
||||
{
|
||||
auto row = view.addRow ();
|
||||
view.set (row, 0, command.first);
|
||||
@@ -133,7 +131,7 @@ int CmdCompletionCommands::execute (std::string& output)
|
||||
{
|
||||
// Get a list of all commands.
|
||||
std::vector <std::string> commands;
|
||||
for (const auto& command : context.commands)
|
||||
for (const auto& command : Context::getContext ().commands)
|
||||
commands.push_back (command.first);
|
||||
|
||||
// Sort alphabetically.
|
||||
@@ -199,7 +197,7 @@ int CmdZshCommands::execute (std::string& output)
|
||||
// denominator alternative: a custom struct type.
|
||||
|
||||
std::vector <ZshCommand> commands;
|
||||
for (auto& command : context.commands)
|
||||
for (auto& command : Context::getContext ().commands)
|
||||
{
|
||||
ZshCommand zshCommand {command.second->category (),
|
||||
command.first,
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdConfig::CmdConfig ()
|
||||
{
|
||||
@@ -59,7 +57,7 @@ bool CmdConfig::setConfigVariable (
|
||||
{
|
||||
// Read .taskrc (or equivalent)
|
||||
std::vector <std::string> contents;
|
||||
File::read (context.config.file (), contents);
|
||||
File::read (Context::getContext ().config.file (), contents);
|
||||
|
||||
auto found = false;
|
||||
auto change = false;
|
||||
@@ -76,7 +74,7 @@ bool CmdConfig::setConfigVariable (
|
||||
{
|
||||
found = true;
|
||||
if (!confirmation ||
|
||||
confirm (format ("Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?", name, context.config.get (name), value)))
|
||||
confirm (format ("Are you sure you want to change the value of '{1}' from '{2}' to '{3}'?", name, Context::getContext ().config.get (name), value)))
|
||||
{
|
||||
line = name + '=' + json::encode (value);
|
||||
|
||||
@@ -98,7 +96,7 @@ bool CmdConfig::setConfigVariable (
|
||||
}
|
||||
|
||||
if (change)
|
||||
File::write (context.config.file (), contents);
|
||||
File::write (Context::getContext ().config.file (), contents);
|
||||
|
||||
return change;
|
||||
}
|
||||
@@ -108,7 +106,7 @@ int CmdConfig::unsetConfigVariable (const std::string& name, bool confirmation /
|
||||
{
|
||||
// Read .taskrc (or equivalent)
|
||||
std::vector <std::string> contents;
|
||||
File::read (context.config.file (), contents);
|
||||
File::read (Context::getContext ().config.file (), contents);
|
||||
|
||||
auto found = false;
|
||||
auto change = false;
|
||||
@@ -143,7 +141,7 @@ int CmdConfig::unsetConfigVariable (const std::string& name, bool confirmation /
|
||||
}
|
||||
|
||||
if (change)
|
||||
File::write (context.config.file (), contents);
|
||||
File::write (Context::getContext ().config.file (), contents);
|
||||
|
||||
if (change && found)
|
||||
return 0;
|
||||
@@ -160,7 +158,7 @@ int CmdConfig::execute (std::string& output)
|
||||
std::stringstream out;
|
||||
|
||||
// Get the non-attribute, non-fancy command line arguments.
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::vector <std::string> words = Context::getContext ().cli2.getWords ();
|
||||
|
||||
// Support:
|
||||
// task config name value # set name to value
|
||||
@@ -168,7 +166,7 @@ int CmdConfig::execute (std::string& output)
|
||||
// task config name # remove name
|
||||
if (words.size ())
|
||||
{
|
||||
auto confirmation = context.config.getBoolean ("confirmation");
|
||||
auto confirmation = Context::getContext ().config.getBoolean ("confirmation");
|
||||
auto found = false;
|
||||
|
||||
auto name = words[0];
|
||||
@@ -214,7 +212,7 @@ int CmdConfig::execute (std::string& output)
|
||||
// Show feedback depending on whether .taskrc has been rewritten
|
||||
if (change)
|
||||
{
|
||||
out << format ("Config file {1} modified.", context.config.file ())
|
||||
out << format ("Config file {1} modified.", Context::getContext ().config.file ())
|
||||
<< '\n';
|
||||
}
|
||||
else
|
||||
@@ -250,7 +248,7 @@ CmdCompletionConfig::CmdCompletionConfig ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdCompletionConfig::execute (std::string& output)
|
||||
{
|
||||
auto configs = context.config.all ();
|
||||
auto configs = Context::getContext ().config.all ();
|
||||
std::sort (configs.begin (), configs.end ());
|
||||
|
||||
for (const auto& config : configs)
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include <shared.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdContext::CmdContext ()
|
||||
{
|
||||
@@ -60,7 +58,7 @@ int CmdContext::execute (std::string& output)
|
||||
std::stringstream out;
|
||||
|
||||
// Get the non-attribute, non-fancy command line arguments.
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () > 0)
|
||||
{
|
||||
auto subcommand = words[0];
|
||||
@@ -110,7 +108,7 @@ std::vector <std::string> CmdContext::getContexts ()
|
||||
{
|
||||
std::vector <std::string> contexts;
|
||||
|
||||
for (auto& name : context.config)
|
||||
for (auto& name : Context::getContext ().config)
|
||||
if (name.first.substr (0, 8) == "context.")
|
||||
contexts.push_back (name.first.substr (8));
|
||||
|
||||
@@ -129,7 +127,7 @@ std::vector <std::string> CmdContext::getContexts ()
|
||||
//
|
||||
void CmdContext::defineContext (const std::vector <std::string>& words, std::stringstream& out)
|
||||
{
|
||||
auto confirmation = context.config.getBoolean ("confirmation");
|
||||
auto confirmation = Context::getContext ().config.getBoolean ("confirmation");
|
||||
|
||||
if (words.size () > 2)
|
||||
{
|
||||
@@ -145,12 +143,12 @@ void CmdContext::defineContext (const std::vector <std::string>& words, std::str
|
||||
// Check if the value is a proper filter by filtering current pending.data
|
||||
Filter filter;
|
||||
std::vector <Task> filtered;
|
||||
auto pending = context.tdb2.pending.get_tasks ();
|
||||
auto pending = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
try
|
||||
{
|
||||
// This result is not used, and is just to check validity.
|
||||
context.cli2.addFilter (value);
|
||||
Context::getContext ().cli2.addFilter (value);
|
||||
filter.subset (pending, filtered);
|
||||
}
|
||||
catch (std::string exception)
|
||||
@@ -193,11 +191,11 @@ void CmdContext::deleteContext (const std::vector <std::string>& words, std::str
|
||||
// Delete the specified context
|
||||
auto name = "context." + words[1];
|
||||
|
||||
auto confirmation = context.config.getBoolean ("confirmation");
|
||||
auto confirmation = Context::getContext ().config.getBoolean ("confirmation");
|
||||
auto rc = CmdConfig::unsetConfigVariable(name, confirmation);
|
||||
|
||||
// If the currently set context was deleted, unset it
|
||||
if (context.config.get ("context") == words[1])
|
||||
if (Context::getContext ().config.get ("context") == words[1])
|
||||
CmdConfig::unsetConfigVariable("context", false);
|
||||
|
||||
// Output feedback
|
||||
@@ -226,13 +224,13 @@ void CmdContext::listContexts (std::stringstream& out)
|
||||
std::sort (contexts.begin (), contexts.end ());
|
||||
|
||||
Table table;
|
||||
table.width (context.getWidth ());
|
||||
table.width (Context::getContext ().getWidth ());
|
||||
table.add ("Name");
|
||||
table.add ("Definition");
|
||||
table.add ("Active");
|
||||
setHeaderUnderline (table);
|
||||
|
||||
std::string activeContext = context.config.get ("context");
|
||||
std::string activeContext = Context::getContext ().config.get ("context");
|
||||
|
||||
for (auto& userContext : contexts)
|
||||
{
|
||||
@@ -242,7 +240,7 @@ void CmdContext::listContexts (std::stringstream& out)
|
||||
|
||||
int row = table.addRow ();
|
||||
table.set (row, 0, userContext);
|
||||
table.set (row, 1, context.config.get ("context." + userContext));
|
||||
table.set (row, 1, Context::getContext ().config.get ("context." + userContext));
|
||||
table.set (row, 2, active);
|
||||
}
|
||||
|
||||
@@ -294,13 +292,13 @@ void CmdContext::setContext (const std::vector <std::string>& words, std::string
|
||||
//
|
||||
void CmdContext::showContext (std::stringstream& out)
|
||||
{
|
||||
auto currentContext = context.config.get ("context");
|
||||
auto currentContext = Context::getContext ().config.get ("context");
|
||||
|
||||
if (currentContext == "")
|
||||
out << "No context is currently applied.\n";
|
||||
else
|
||||
{
|
||||
std::string currentFilter = context.config.get ("context." + currentContext);
|
||||
std::string currentFilter = Context::getContext ().config.get ("context." + currentContext);
|
||||
out << format ("Context '{1}' with filter '{2}' is currently applied.\n", currentContext, currentFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdCustom::CmdCustom (
|
||||
const std::string& keyword,
|
||||
@@ -67,10 +65,10 @@ int CmdCustom::execute (std::string& output)
|
||||
auto rc = 0;
|
||||
|
||||
// Load report configuration.
|
||||
auto reportColumns = context.config.get ("report." + _keyword + ".columns");
|
||||
auto reportLabels = context.config.get ("report." + _keyword + ".labels");
|
||||
auto reportSort = context.config.get ("report." + _keyword + ".sort");
|
||||
auto reportFilter = context.config.get ("report." + _keyword + ".filter");
|
||||
auto reportColumns = Context::getContext ().config.get ("report." + _keyword + ".columns");
|
||||
auto reportLabels = Context::getContext ().config.get ("report." + _keyword + ".labels");
|
||||
auto reportSort = Context::getContext ().config.get ("report." + _keyword + ".sort");
|
||||
auto reportFilter = Context::getContext ().config.get ("report." + _keyword + ".filter");
|
||||
|
||||
auto columns = split (reportColumns, ',');
|
||||
validateReportColumns (columns);
|
||||
@@ -87,7 +85,7 @@ int CmdCustom::execute (std::string& output)
|
||||
|
||||
// Add the report filter to any existing filter.
|
||||
if (reportFilter != "")
|
||||
context.cli2.addFilter (reportFilter);
|
||||
Context::getContext ().cli2.addFilter (reportFilter);
|
||||
|
||||
// Apply filter.
|
||||
handleUntil ();
|
||||
@@ -101,10 +99,10 @@ int CmdCustom::execute (std::string& output)
|
||||
sortOrder[0] == "none")
|
||||
{
|
||||
// Assemble a sequence vector that represents the tasks listed in
|
||||
// context.cli2._uuid_ranges, in the order in which they appear. This
|
||||
// Context::getContext ().cli2._uuid_ranges, in the order in which they appear. This
|
||||
// equates to no sorting, just a specified order.
|
||||
sortOrder.clear ();
|
||||
for (auto& i : context.cli2._uuid_list)
|
||||
for (auto& i : Context::getContext ().cli2._uuid_list)
|
||||
for (unsigned int t = 0; t < filtered.size (); ++t)
|
||||
if (filtered[t].get ("uuid") == i)
|
||||
sequence.push_back (t);
|
||||
@@ -123,21 +121,21 @@ int CmdCustom::execute (std::string& output)
|
||||
|
||||
// Configure the view.
|
||||
ViewTask view;
|
||||
view.width (context.getWidth ());
|
||||
view.leftMargin (context.config.getInteger ("indent.report"));
|
||||
view.extraPadding (context.config.getInteger ("row.padding"));
|
||||
view.intraPadding (context.config.getInteger ("column.padding"));
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.leftMargin (Context::getContext ().config.getInteger ("indent.report"));
|
||||
view.extraPadding (Context::getContext ().config.getInteger ("row.padding"));
|
||||
view.intraPadding (Context::getContext ().config.getInteger ("column.padding"));
|
||||
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
Color label (context.config.get ("color.label"));
|
||||
Color label (Context::getContext ().config.get ("color.label"));
|
||||
view.colorHeader (label);
|
||||
|
||||
Color label_sort (context.config.get ("color.label.sort"));
|
||||
Color label_sort (Context::getContext ().config.get ("color.label.sort"));
|
||||
view.colorSortHeader (label_sort);
|
||||
|
||||
// If an alternating row color is specified, notify the table.
|
||||
Color alternate (context.config.get ("color.alternate"));
|
||||
Color alternate (Context::getContext ().config.get ("color.alternate"));
|
||||
if (alternate.nontrivial ())
|
||||
{
|
||||
view.colorOdd (alternate);
|
||||
@@ -154,7 +152,7 @@ int CmdCustom::execute (std::string& output)
|
||||
std::string name;
|
||||
bool ascending;
|
||||
bool breakIndicator;
|
||||
context.decomposeSortField (so, name, ascending, breakIndicator);
|
||||
Context::getContext ().decomposeSortField (so, name, ascending, breakIndicator);
|
||||
|
||||
if (breakIndicator)
|
||||
view.addBreak (name);
|
||||
@@ -178,9 +176,9 @@ int CmdCustom::execute (std::string& output)
|
||||
|
||||
// How many lines taken up by table header?
|
||||
int table_header = 0;
|
||||
if (context.verbose ("label"))
|
||||
if (Context::getContext ().verbose ("label"))
|
||||
{
|
||||
if (context.color () && context.config.getBoolean ("fontunderline"))
|
||||
if (Context::getContext ().color () && Context::getContext ().config.getBoolean ("fontunderline"))
|
||||
table_header = 1; // Underlining doesn't use extra line.
|
||||
else
|
||||
table_header = 2; // Dashes use an extra line.
|
||||
@@ -189,15 +187,15 @@ int CmdCustom::execute (std::string& output)
|
||||
// Report output can be limited by rows or lines.
|
||||
auto maxrows = 0;
|
||||
auto maxlines = 0;
|
||||
context.getLimits (maxrows, maxlines);
|
||||
Context::getContext ().getLimits (maxrows, maxlines);
|
||||
|
||||
// Adjust for fluff in the output.
|
||||
if (maxlines)
|
||||
maxlines -= table_header
|
||||
+ (context.verbose ("blank") ? 1 : 0)
|
||||
+ (context.verbose ("footnote") ? context.footnotes.size () : 0)
|
||||
+ (context.verbose ("affected") ? 1 : 0)
|
||||
+ context.config.getInteger ("reserved.lines"); // For prompt, etc.
|
||||
+ (Context::getContext ().verbose ("blank") ? 1 : 0)
|
||||
+ (Context::getContext ().verbose ("footnote") ? Context::getContext ().footnotes.size () : 0)
|
||||
+ (Context::getContext ().verbose ("affected") ? 1 : 0)
|
||||
+ Context::getContext ().config.getInteger ("reserved.lines"); // For prompt, etc.
|
||||
|
||||
// Render.
|
||||
std::stringstream out;
|
||||
@@ -211,7 +209,7 @@ int CmdCustom::execute (std::string& output)
|
||||
<< optionalBlankLine ();
|
||||
|
||||
// Print the number of rendered tasks
|
||||
if (context.verbose ("affected"))
|
||||
if (Context::getContext ().verbose ("affected"))
|
||||
{
|
||||
out << (filtered.size () == 1
|
||||
? "1 task"
|
||||
@@ -229,7 +227,7 @@ int CmdCustom::execute (std::string& output)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("No matches.");
|
||||
Context::getContext ().footnote ("No matches.");
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#define STRING_CMD_DELETE_TASK_R "Deleting recurring task {1} '{2}'."
|
||||
#define STRING_CMD_DELETE_CONFIRM_R "This is a recurring task. Do you want to delete all pending recurrences of this same task?"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDelete::CmdDelete ()
|
||||
{
|
||||
@@ -67,7 +65,7 @@ int CmdDelete::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,21 +93,21 @@ int CmdDelete::execute (std::string&)
|
||||
{
|
||||
updateRecurrenceMask (task);
|
||||
++count;
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
feedback_affected ("Deleting task {1} '{2}'.", task);
|
||||
feedback_unblocked (task);
|
||||
dependencyChainOnComplete (task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task);
|
||||
|
||||
// Delete siblings.
|
||||
if (task.has ("parent"))
|
||||
{
|
||||
if ((context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if ((Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm (STRING_CMD_DELETE_CONFIRM_R)) ||
|
||||
context.config.getBoolean ("recurrence.confirmation"))
|
||||
Context::getContext ().config.getBoolean ("recurrence.confirmation"))
|
||||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (task);
|
||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
sibling.modify (Task::modAnnotate);
|
||||
@@ -118,7 +116,7 @@ int CmdDelete::execute (std::string&)
|
||||
sibling.setAsNow ("end");
|
||||
|
||||
updateRecurrenceMask (sibling);
|
||||
context.tdb2.modify (sibling);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
feedback_affected (STRING_CMD_DELETE_TASK_R, sibling);
|
||||
feedback_unblocked (sibling);
|
||||
++count;
|
||||
@@ -126,21 +124,21 @@ int CmdDelete::execute (std::string&)
|
||||
|
||||
// Delete the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task.get ("parent"), parent);
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
parent.setStatus (Task::deleted);
|
||||
if (! parent.has ("end"))
|
||||
parent.setAsNow ("end");
|
||||
|
||||
context.tdb2.modify (parent);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
}
|
||||
|
||||
// Task potentially has child tasks - optionally delete them.
|
||||
else
|
||||
{
|
||||
std::vector <Task> children = context.tdb2.children (task);
|
||||
std::vector <Task> children = Context::getContext ().tdb2.children (task);
|
||||
if (children.size () &&
|
||||
(context.config.getBoolean ("recurrence.confirmation") ||
|
||||
(Context::getContext ().config.getBoolean ("recurrence.confirmation") ||
|
||||
confirm (STRING_CMD_DELETE_CONFIRM_R)))
|
||||
{
|
||||
for (auto& child : children)
|
||||
@@ -151,7 +149,7 @@ int CmdDelete::execute (std::string&)
|
||||
child.setAsNow ("end");
|
||||
|
||||
updateRecurrenceMask (child);
|
||||
context.tdb2.modify (child);
|
||||
Context::getContext ().tdb2.modify (child);
|
||||
feedback_affected (STRING_CMD_DELETE_TASK_R, child);
|
||||
feedback_unblocked (child);
|
||||
++count;
|
||||
@@ -180,7 +178,7 @@ int CmdDelete::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Deleted {1} task." : "Deleted {1} tasks.", count);
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#define STRING_CMD_DENO_1 "Denotated {1} task."
|
||||
#define STRING_CMD_DENO_N "Denotated {1} tasks."
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDenotate::CmdDenotate ()
|
||||
{
|
||||
@@ -61,7 +59,7 @@ int CmdDenotate::execute (std::string&)
|
||||
{
|
||||
auto rc = 0;
|
||||
auto count = 0;
|
||||
auto sensitive = context.config.getBoolean ("search.case.sensitive");
|
||||
auto sensitive = Context::getContext ().config.getBoolean ("search.case.sensitive");
|
||||
|
||||
// Apply filter.
|
||||
Filter filter;
|
||||
@@ -69,13 +67,13 @@ int CmdDenotate::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Extract all the ORIGINAL MODIFICATION args as simple text patterns.
|
||||
std::string pattern = "";
|
||||
for (auto& a : context.cli2._args)
|
||||
for (auto& a : Context::getContext ().cli2._args)
|
||||
{
|
||||
if (a.hasTag ("MISCELLANEOUS"))
|
||||
{
|
||||
@@ -136,9 +134,9 @@ int CmdDenotate::execute (std::string&)
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
++count;
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
feedback_affected (format ("Found annotation '{1}' and deleted it.", anno));
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
}
|
||||
else
|
||||
@@ -159,7 +157,7 @@ int CmdDenotate::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? STRING_CMD_DENO_1 : STRING_CMD_DENO_N, count);
|
||||
return rc;
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#include <gnutls/gnutls.h>
|
||||
#endif
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDiagnostics::CmdDiagnostics ()
|
||||
{
|
||||
@@ -69,7 +67,7 @@ CmdDiagnostics::CmdDiagnostics ()
|
||||
int CmdDiagnostics::execute (std::string& output)
|
||||
{
|
||||
Color bold;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
bold = Color ("bold");
|
||||
|
||||
std::stringstream out;
|
||||
@@ -160,7 +158,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
<< "\n\n";
|
||||
|
||||
// Config: .taskrc found, readable, writable
|
||||
File rcFile (context.config.file ());
|
||||
File rcFile (Context::getContext ().config.file ());
|
||||
out << bold.colorize ("Configuration")
|
||||
<< '\n'
|
||||
<< " File: " << rcFile._data << ' '
|
||||
@@ -174,7 +172,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
<< '\n';
|
||||
|
||||
// Config: data.location found, readable, writable
|
||||
File location (context.config.get ("data.location"));
|
||||
File location (Context::getContext ().config.get ("data.location"));
|
||||
out << " Data: " << location._data << ' '
|
||||
<< (location.exists ()
|
||||
? "(found)"
|
||||
@@ -198,31 +196,31 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
<< '\n';
|
||||
|
||||
out << " Locking: "
|
||||
<< (context.config.getBoolean ("locking")
|
||||
<< (Context::getContext ().config.getBoolean ("locking")
|
||||
? "Enabled"
|
||||
: "Disabled")
|
||||
<< '\n';
|
||||
|
||||
out << " GC: "
|
||||
<< (context.config.getBoolean ("gc")
|
||||
<< (Context::getContext ().config.getBoolean ("gc")
|
||||
? "Enabled"
|
||||
: "Disabled")
|
||||
<< '\n';
|
||||
|
||||
// Determine rc.editor/$EDITOR/$VISUAL.
|
||||
char* peditor;
|
||||
if (context.config.get ("editor") != "")
|
||||
out << " rc.editor: " << context.config.get ("editor") << '\n';
|
||||
if (Context::getContext ().config.get ("editor") != "")
|
||||
out << " rc.editor: " << Context::getContext ().config.get ("editor") << '\n';
|
||||
else if ((peditor = getenv ("VISUAL")) != NULL)
|
||||
out << " $VISUAL: " << peditor << '\n';
|
||||
else if ((peditor = getenv ("EDITOR")) != NULL)
|
||||
out << " $EDITOR: " << peditor << '\n';
|
||||
|
||||
out << " Server: "
|
||||
<< context.config.get ("taskd.server")
|
||||
<< Context::getContext ().config.get ("taskd.server")
|
||||
<< '\n';
|
||||
|
||||
auto ca_pem = context.config.get ("taskd.ca");
|
||||
auto ca_pem = Context::getContext ().config.get ("taskd.ca");
|
||||
out << " CA: ";
|
||||
if (ca_pem != "")
|
||||
{
|
||||
@@ -238,7 +236,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
else
|
||||
out << "-\n";
|
||||
|
||||
auto cert_pem = context.config.get ("taskd.certificate");
|
||||
auto cert_pem = Context::getContext ().config.get ("taskd.certificate");
|
||||
out << "Certificate: ";
|
||||
if (cert_pem != "")
|
||||
{
|
||||
@@ -254,7 +252,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
else
|
||||
out << "-\n";
|
||||
|
||||
auto key_pem = context.config.get ("taskd.key");
|
||||
auto key_pem = Context::getContext ().config.get ("taskd.key");
|
||||
out << " Key: ";
|
||||
if (key_pem != "")
|
||||
{
|
||||
@@ -270,7 +268,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
else
|
||||
out << "-\n";
|
||||
|
||||
auto trust_value = context.config.get ("taskd.trust");
|
||||
auto trust_value = Context::getContext ().config.get ("taskd.trust");
|
||||
if (trust_value == "strict" ||
|
||||
trust_value == "ignore hostname" ||
|
||||
trust_value == "allow all")
|
||||
@@ -279,11 +277,11 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
out << " Trust: Bad value - see 'man taskrc'\n";
|
||||
|
||||
out << " Ciphers: "
|
||||
<< context.config.get ("taskd.ciphers")
|
||||
<< Context::getContext ().config.get ("taskd.ciphers")
|
||||
<< '\n';
|
||||
|
||||
// Get credentials, but mask out the key.
|
||||
auto credentials = context.config.get ("taskd.credentials");
|
||||
auto credentials = Context::getContext ().config.get ("taskd.credentials");
|
||||
auto last_slash = credentials.rfind ('/');
|
||||
if (last_slash != std::string::npos)
|
||||
credentials = credentials.substr (0, last_slash)
|
||||
@@ -296,26 +294,26 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
|
||||
// Display hook status.
|
||||
Path hookLocation;
|
||||
if (context.config.has ("hooks.location"))
|
||||
if (Context::getContext ().config.has ("hooks.location"))
|
||||
{
|
||||
hookLocation = Path (context.config.get ("hooks.location"));
|
||||
hookLocation = Path (Context::getContext ().config.get ("hooks.location"));
|
||||
}
|
||||
else
|
||||
{
|
||||
hookLocation = Path (context.config.get ("data.location"));
|
||||
hookLocation = Path (Context::getContext ().config.get ("data.location"));
|
||||
hookLocation += "hooks";
|
||||
}
|
||||
|
||||
out << bold.colorize ("Hooks")
|
||||
<< '\n'
|
||||
<< " System: "
|
||||
<< (context.config.getBoolean ("hooks") ? "Enabled" : "Disabled")
|
||||
<< (Context::getContext ().config.getBoolean ("hooks") ? "Enabled" : "Disabled")
|
||||
<< '\n'
|
||||
<< " Location: "
|
||||
<< static_cast <std::string> (hookLocation)
|
||||
<< '\n';
|
||||
|
||||
auto hooks = context.hooks.list ();
|
||||
auto hooks = Context::getContext ().hooks.list ();
|
||||
if (hooks.size ())
|
||||
{
|
||||
unsigned int longest = 0;
|
||||
@@ -397,13 +395,13 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
|
||||
// Report terminal dimensions.
|
||||
out << " Terminal: "
|
||||
<< context.getWidth ()
|
||||
<< Context::getContext ().getWidth ()
|
||||
<< 'x'
|
||||
<< context.getHeight ()
|
||||
<< Context::getContext ().getHeight ()
|
||||
<< '\n';
|
||||
|
||||
// Scan tasks for duplicate UUIDs.
|
||||
auto all = context.tdb2.all_tasks ();
|
||||
auto all = Context::getContext ().tdb2.all_tasks ();
|
||||
std::map <std::string, int> seen;
|
||||
std::vector <std::string> dups;
|
||||
std::string uuid;
|
||||
@@ -442,7 +440,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
// Check dependencies
|
||||
for (auto& uuid : task.getDependencyUUIDs ())
|
||||
{
|
||||
if (! context.tdb2.has (uuid))
|
||||
if (! Context::getContext ().tdb2.has (uuid))
|
||||
{
|
||||
out << " "
|
||||
<< format ("Task {1} depends on nonexistent task: {2}", task.get ("uuid"), uuid)
|
||||
@@ -454,7 +452,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||
// Check recurrence parent
|
||||
auto parentUUID = task.get ("parent");
|
||||
|
||||
if (parentUUID != "" && ! context.tdb2.has (parentUUID))
|
||||
if (parentUUID != "" && ! Context::getContext ().tdb2.has (parentUUID))
|
||||
{
|
||||
out << " "
|
||||
<< format ("Task {1} has nonexistent recurrence template {2}", task.get ("uuid"), parentUUID)
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDone::CmdDone ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdDone::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -92,21 +90,21 @@ int CmdDone::execute (std::string&)
|
||||
if (task.has ("start"))
|
||||
{
|
||||
task.remove ("start");
|
||||
if (context.config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
||||
if (Context::getContext ().config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (Context::getContext ().config.get ("journal.time.stop.annotation"));
|
||||
}
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
updateRecurrenceMask (task);
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Completed task {1} '{2}'.", task);
|
||||
feedback_unblocked (task);
|
||||
if (!nagged)
|
||||
nagged = nag (task);
|
||||
dependencyChainOnComplete (task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task);
|
||||
}
|
||||
else
|
||||
@@ -130,7 +128,7 @@ int CmdDone::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Completed {1} task." : "Completed {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdDuplicate::CmdDuplicate ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdDuplicate::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -109,21 +107,21 @@ int CmdDuplicate::execute (std::string&)
|
||||
task.get ("description")),
|
||||
filtered.size ()))
|
||||
{
|
||||
context.tdb2.add (dup);
|
||||
Context::getContext ().tdb2.add (dup);
|
||||
++count;
|
||||
feedback_affected ("Duplicated task {1} '{2}'.", task);
|
||||
|
||||
auto status = dup.getStatus ();
|
||||
if (context.verbose ("new-id") &&
|
||||
if (Context::getContext ().verbose ("new-id") &&
|
||||
(status == Task::pending ||
|
||||
status == Task::waiting))
|
||||
std::cout << format ("Created task {1}.\n", dup.id);
|
||||
|
||||
else if (context.verbose ("new-uuid") &&
|
||||
else if (Context::getContext ().verbose ("new-uuid") &&
|
||||
status != Task::recurring)
|
||||
std::cout << format ("Created task {1}.\n", dup.get ("uuid"));
|
||||
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task);
|
||||
}
|
||||
else
|
||||
@@ -138,7 +136,7 @@ int CmdDuplicate::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Duplicated {1} task." : "Duplicated {1} tasks.", count);
|
||||
|
||||
|
||||
@@ -51,8 +51,6 @@
|
||||
#define STRING_EDIT_UNTIL_MOD "Until date modified."
|
||||
#define STRING_EDIT_WAIT_MOD "Wait date modified."
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdEdit::CmdEdit ()
|
||||
{
|
||||
@@ -84,7 +82,7 @@ int CmdEdit::execute (std::string&)
|
||||
|
||||
if (! filtered.size ())
|
||||
{
|
||||
context.footnote ("No matches.");
|
||||
Context::getContext ().footnote ("No matches.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,7 +93,7 @@ int CmdEdit::execute (std::string&)
|
||||
if (result == CmdEdit::editResult::error)
|
||||
break;
|
||||
else if (result == CmdEdit::editResult::changes)
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -201,7 +199,7 @@ std::string CmdEdit::formatDuration (
|
||||
std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||
{
|
||||
std::stringstream before;
|
||||
auto verbose = context.verbose ("edit");
|
||||
auto verbose = Context::getContext ().verbose ("edit");
|
||||
|
||||
if (verbose)
|
||||
before << "# The 'task <id> edit' command allows you to modify all aspects of a task\n"
|
||||
@@ -269,7 +267,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||
allDeps << ",";
|
||||
|
||||
Task t;
|
||||
context.tdb2.get (dependencies[i], t);
|
||||
Context::getContext ().tdb2.get (dependencies[i], t);
|
||||
if (t.getStatus () == Task::pending ||
|
||||
t.getStatus () == Task::waiting)
|
||||
allDeps << t.id;
|
||||
@@ -284,8 +282,8 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||
|
||||
// UDAs
|
||||
std::vector <std::string> udas;
|
||||
for (auto& col : context.columns)
|
||||
if (context.config.get ("uda." + col.first + ".type") != "")
|
||||
for (auto& col : Context::getContext ().columns)
|
||||
if (Context::getContext ().config.get ("uda." + col.first + ".type") != "")
|
||||
udas.push_back (col.first);
|
||||
|
||||
if (udas.size ())
|
||||
@@ -299,7 +297,7 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
||||
if (pad > 0)
|
||||
padding = std::string (pad, ' ');
|
||||
|
||||
std::string type = context.config.get ("uda." + uda + ".type");
|
||||
std::string type = Context::getContext ().config.get ("uda." + uda + ".type");
|
||||
if (type == "string" || type == "numeric")
|
||||
before << " UDA " << uda << ": " << padding << task.get (uda) << '\n';
|
||||
else if (type == "date")
|
||||
@@ -339,12 +337,12 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
context.footnote ("Project modified.");
|
||||
Context::getContext ().footnote ("Project modified.");
|
||||
task.set ("project", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("Project deleted.");
|
||||
Context::getContext ().footnote ("Project deleted.");
|
||||
task.remove ("project");
|
||||
}
|
||||
}
|
||||
@@ -360,7 +358,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
context.footnote ("Description modified.");
|
||||
Context::getContext ().footnote ("Description modified.");
|
||||
task.set ("description", value);
|
||||
}
|
||||
else
|
||||
@@ -373,7 +371,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "entry", dateformat))
|
||||
{
|
||||
context.footnote ("Creation date modified.");
|
||||
Context::getContext ().footnote ("Creation date modified.");
|
||||
task.set ("entry", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -388,13 +386,13 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "start", dateformat))
|
||||
{
|
||||
context.footnote (STRING_EDIT_START_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_START_MOD);
|
||||
task.set ("start", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (STRING_EDIT_START_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_START_MOD);
|
||||
task.set ("start", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -402,7 +400,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (task.get ("start") != "")
|
||||
{
|
||||
context.footnote ("Start date removed.");
|
||||
Context::getContext ().footnote ("Start date removed.");
|
||||
task.remove ("start");
|
||||
}
|
||||
}
|
||||
@@ -415,7 +413,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "end", dateformat))
|
||||
{
|
||||
context.footnote ("End date modified.");
|
||||
Context::getContext ().footnote ("End date modified.");
|
||||
task.set ("end", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -426,7 +424,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (task.get ("end") != "")
|
||||
{
|
||||
context.footnote ("End date removed.");
|
||||
Context::getContext ().footnote ("End date removed.");
|
||||
task.setStatus (Task::pending);
|
||||
task.remove ("end");
|
||||
}
|
||||
@@ -440,13 +438,13 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "scheduled", dateformat))
|
||||
{
|
||||
context.footnote (STRING_EDIT_SCHED_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_SCHED_MOD);
|
||||
task.set ("scheduled", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (STRING_EDIT_SCHED_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_SCHED_MOD);
|
||||
task.set ("scheduled", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -454,7 +452,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (task.get ("scheduled") != "")
|
||||
{
|
||||
context.footnote ("Scheduled date removed.");
|
||||
Context::getContext ().footnote ("Scheduled date removed.");
|
||||
task.remove ("scheduled");
|
||||
}
|
||||
}
|
||||
@@ -467,13 +465,13 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "due", dateformat))
|
||||
{
|
||||
context.footnote (STRING_EDIT_DUE_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_DUE_MOD);
|
||||
task.set ("due", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (STRING_EDIT_DUE_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_DUE_MOD);
|
||||
task.set ("due", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -484,11 +482,11 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
if (task.getStatus () == Task::recurring ||
|
||||
task.get ("parent") != "")
|
||||
{
|
||||
context.footnote ("Cannot remove a due date from a recurring task.");
|
||||
Context::getContext ().footnote ("Cannot remove a due date from a recurring task.");
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("Due date removed.");
|
||||
Context::getContext ().footnote ("Due date removed.");
|
||||
task.remove ("due");
|
||||
}
|
||||
}
|
||||
@@ -502,13 +500,13 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "until", dateformat))
|
||||
{
|
||||
context.footnote (STRING_EDIT_UNTIL_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_UNTIL_MOD);
|
||||
task.set ("until", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (STRING_EDIT_UNTIL_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_UNTIL_MOD);
|
||||
task.set ("until", Datetime (value, dateformat).toEpochString ());
|
||||
}
|
||||
}
|
||||
@@ -516,7 +514,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (task.get ("until") != "")
|
||||
{
|
||||
context.footnote ("Until date removed.");
|
||||
Context::getContext ().footnote ("Until date removed.");
|
||||
task.remove ("until");
|
||||
}
|
||||
}
|
||||
@@ -531,7 +529,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
std::string::size_type idx = 0;
|
||||
if (p.parse (value, idx))
|
||||
{
|
||||
context.footnote ("Recurrence modified.");
|
||||
Context::getContext ().footnote ("Recurrence modified.");
|
||||
if (task.get ("due") != "")
|
||||
{
|
||||
task.set ("recur", value);
|
||||
@@ -545,7 +543,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("Recurrence removed.");
|
||||
Context::getContext ().footnote ("Recurrence removed.");
|
||||
task.setStatus (Task::pending);
|
||||
task.remove ("recur");
|
||||
task.remove ("until");
|
||||
@@ -562,14 +560,14 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != formatDate (task, "wait", dateformat))
|
||||
{
|
||||
context.footnote (STRING_EDIT_WAIT_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_WAIT_MOD);
|
||||
task.set ("wait", Datetime (value, dateformat).toEpochString ());
|
||||
task.setStatus (Task::waiting);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (STRING_EDIT_WAIT_MOD);
|
||||
Context::getContext ().footnote (STRING_EDIT_WAIT_MOD);
|
||||
task.set ("wait", Datetime (value, dateformat).toEpochString ());
|
||||
task.setStatus (Task::waiting);
|
||||
}
|
||||
@@ -578,7 +576,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (task.get ("wait") != "")
|
||||
{
|
||||
context.footnote ("Wait date removed.");
|
||||
Context::getContext ().footnote ("Wait date removed.");
|
||||
task.remove ("wait");
|
||||
task.setStatus (Task::pending);
|
||||
}
|
||||
@@ -590,12 +588,12 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
context.footnote ("Parent UUID modified.");
|
||||
Context::getContext ().footnote ("Parent UUID modified.");
|
||||
task.set ("parent", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("Parent UUID removed.");
|
||||
Context::getContext ().footnote ("Parent UUID removed.");
|
||||
task.remove ("parent");
|
||||
}
|
||||
}
|
||||
@@ -659,9 +657,9 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
}
|
||||
|
||||
// UDAs
|
||||
for (auto& col : context.columns)
|
||||
for (auto& col : Context::getContext ().columns)
|
||||
{
|
||||
auto type = context.config.get ("uda." + col.first + ".type");
|
||||
auto type = Context::getContext ().config.get ("uda." + col.first + ".type");
|
||||
if (type != "")
|
||||
{
|
||||
auto value = findValue (after, "\n UDA " + col.first + ":");
|
||||
@@ -672,7 +670,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
{
|
||||
if (value != "")
|
||||
{
|
||||
context.footnote (format ("UDA {1} modified.", col.first));
|
||||
Context::getContext ().footnote (format ("UDA {1} modified.", col.first));
|
||||
|
||||
if (type == "string")
|
||||
{
|
||||
@@ -699,7 +697,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote (format ("UDA {1} deleted.", col.first));
|
||||
Context::getContext ().footnote (format ("UDA {1} deleted.", col.first));
|
||||
task.remove (col.first);
|
||||
}
|
||||
}
|
||||
@@ -727,7 +725,7 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
||||
CmdEdit::editResult CmdEdit::editFile (Task& task)
|
||||
{
|
||||
// Check for file permissions.
|
||||
Directory location (context.config.get ("data.location"));
|
||||
Directory location (Context::getContext ().config.get ("data.location"));
|
||||
if (! location.writable ())
|
||||
throw std::string ("Your data.location directory is not writable.");
|
||||
|
||||
@@ -738,9 +736,9 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.dateformat.edit
|
||||
// rc.dateformat
|
||||
auto dateformat = context.config.get ("dateformat.edit");
|
||||
auto dateformat = Context::getContext ().config.get ("dateformat.edit");
|
||||
if (dateformat == "")
|
||||
dateformat = context.config.get ("dateformat");
|
||||
dateformat = Context::getContext ().config.get ("dateformat");
|
||||
|
||||
// Change directory for the editor
|
||||
auto current_dir = Directory::cwd ();
|
||||
@@ -758,7 +756,7 @@ CmdEdit::editResult CmdEdit::editFile (Task& task)
|
||||
File::write (file.str (), before);
|
||||
|
||||
// Determine correct editor: .taskrc:editor > $VISUAL > $EDITOR > vi
|
||||
auto editor = context.config.get ("editor");
|
||||
auto editor = Context::getContext ().config.get ("editor");
|
||||
char* peditor = getenv ("VISUAL");
|
||||
if (editor == "" && peditor) editor = std::string (peditor);
|
||||
peditor = getenv ("EDITOR");
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <Context.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdExec::CmdExec ()
|
||||
{
|
||||
@@ -51,7 +49,7 @@ CmdExec::CmdExec ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdExec::execute (std::string&)
|
||||
{
|
||||
return system (join (" ", context.cli2.getWords ()).c_str ());
|
||||
return system (join (" ", Context::getContext ().cli2.getWords ()).c_str ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <Filter.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdExport::CmdExport ()
|
||||
{
|
||||
@@ -68,11 +66,11 @@ int CmdExport::execute (std::string& output)
|
||||
// Obey 'limit:N'.
|
||||
int rows = 0;
|
||||
int lines = 0;
|
||||
context.getLimits (rows, lines);
|
||||
Context::getContext ().getLimits (rows, lines);
|
||||
int limit = (rows > lines ? rows : lines);
|
||||
|
||||
// Is output contained within a JSON array?
|
||||
bool json_array = context.config.getBoolean ("json.array");
|
||||
bool json_array = Context::getContext ().config.getBoolean ("json.array");
|
||||
|
||||
// Compose output.
|
||||
if (json_array)
|
||||
@@ -101,7 +99,7 @@ int CmdExport::execute (std::string& output)
|
||||
if (json_array)
|
||||
output += "]\n";
|
||||
|
||||
context.time_render_us += timer.total_us ();
|
||||
Context::getContext ().time_render_us += timer.total_us ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdGet::CmdGet ()
|
||||
{
|
||||
@@ -60,7 +58,7 @@ CmdGet::CmdGet ()
|
||||
int CmdGet::execute (std::string& output)
|
||||
{
|
||||
std::vector <std::string> results;
|
||||
for (auto& arg : context.cli2._args)
|
||||
for (auto& arg : Context::getContext ().cli2._args)
|
||||
{
|
||||
switch (arg._lextype)
|
||||
{
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdHelp::CmdHelp ()
|
||||
{
|
||||
@@ -54,7 +52,7 @@ CmdHelp::CmdHelp ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdHelp::execute (std::string& output)
|
||||
{
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () == 1 && closeEnough ("usage", words[0]))
|
||||
output = '\n'
|
||||
+ composeUsage ()
|
||||
@@ -183,7 +181,7 @@ int CmdHelp::execute (std::string& output)
|
||||
std::string CmdHelp::composeUsage () const
|
||||
{
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("");
|
||||
view.add ("");
|
||||
view.add ("");
|
||||
@@ -196,7 +194,7 @@ std::string CmdHelp::composeUsage () const
|
||||
|
||||
// Obsolete method of getting a list of all commands.
|
||||
std::vector <std::string> all;
|
||||
for (auto& cmd : context.commands)
|
||||
for (auto& cmd : Context::getContext ().commands)
|
||||
all.push_back (cmd.first);
|
||||
|
||||
// Sort alphabetically by usage.
|
||||
@@ -208,8 +206,8 @@ std::string CmdHelp::composeUsage () const
|
||||
if (name[0] != '_')
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 1, context.commands[name]->usage ());
|
||||
view.set (row, 2, context.commands[name]->description ());
|
||||
view.set (row, 1, Context::getContext ().commands[name]->usage ());
|
||||
view.set (row, 2, Context::getContext ().commands[name]->description ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,8 +217,8 @@ std::string CmdHelp::composeUsage () const
|
||||
if (name[0] == '_')
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 1, context.commands[name]->usage ());
|
||||
view.set (row, 2, context.commands[name]->description ());
|
||||
view.set (row, 1, Context::getContext ().commands[name]->usage ());
|
||||
view.set (row, 2, Context::getContext ().commands[name]->description ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,7 +226,7 @@ std::string CmdHelp::composeUsage () const
|
||||
row = view.addRow ();
|
||||
view.set (row, 1, " ");
|
||||
|
||||
for (auto& alias : context.config)
|
||||
for (auto& alias : Context::getContext ().config)
|
||||
{
|
||||
if (alias.first.substr (0, 6) == "alias.")
|
||||
{
|
||||
|
||||
@@ -42,8 +42,6 @@
|
||||
#define STRING_CMD_HISTORY_COMP "Completed"
|
||||
#define STRING_CMD_HISTORY_DEL "Deleted"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template<class HistoryStrategy>
|
||||
CmdHistoryBase<HistoryStrategy>::CmdHistoryBase ()
|
||||
@@ -66,21 +64,21 @@ CmdHistoryBase<HistoryStrategy>::CmdHistoryBase ()
|
||||
template<class HistoryStrategy>
|
||||
void CmdHistoryBase<HistoryStrategy>::outputGraphical (std::string& output)
|
||||
{
|
||||
auto widthOfBar = context.getWidth () - HistoryStrategy::labelWidth;
|
||||
auto widthOfBar = Context::getContext ().getWidth () - HistoryStrategy::labelWidth;
|
||||
|
||||
// Now build the view.
|
||||
Table view;
|
||||
setHeaderUnderline (view);
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
|
||||
HistoryStrategy::setupTableDates (view);
|
||||
|
||||
view.add ("Number Added/Completed/Deleted", true, false); // Fixed.
|
||||
|
||||
Color color_add (context.config.get ("color.history.add"));
|
||||
Color color_done (context.config.get ("color.history.done"));
|
||||
Color color_delete (context.config.get ("color.history.delete"));
|
||||
Color label (context.config.get ("color.label"));
|
||||
Color color_add (Context::getContext ().config.get ("color.history.add"));
|
||||
Color color_done (Context::getContext ().config.get ("color.history.done"));
|
||||
Color color_delete (Context::getContext ().config.get ("color.history.delete"));
|
||||
Color label (Context::getContext ().config.get ("color.label"));
|
||||
|
||||
// Determine the longest line, and the longest "added" line.
|
||||
auto maxAddedLine = 0;
|
||||
@@ -121,7 +119,7 @@ void CmdHistoryBase<HistoryStrategy>::outputGraphical (std::string& output)
|
||||
unsigned int deletedBar = (widthOfBar * deletedGroup[i.first]) / maxLine;
|
||||
|
||||
std::string bar;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
std::string aBar;
|
||||
if (addedGroup[i.first])
|
||||
@@ -173,7 +171,7 @@ void CmdHistoryBase<HistoryStrategy>::outputGraphical (std::string& output)
|
||||
<< view.render ()
|
||||
<< '\n';
|
||||
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
out << format ("Legend: {1}, {2}, {3}",
|
||||
color_add.colorize (STRING_CMD_HISTORY_ADDED),
|
||||
color_done.colorize (STRING_CMD_HISTORY_COMP),
|
||||
@@ -185,7 +183,7 @@ void CmdHistoryBase<HistoryStrategy>::outputGraphical (std::string& output)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("No tasks.");
|
||||
Context::getContext ().footnote ("No tasks.");
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
@@ -198,7 +196,7 @@ void CmdHistoryBase<HistoryStrategy>::outputTabular (std::string& output)
|
||||
{
|
||||
Table view;
|
||||
setHeaderUnderline (view);
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
|
||||
HistoryStrategy::setupTableDates (view);
|
||||
|
||||
@@ -245,7 +243,7 @@ void CmdHistoryBase<HistoryStrategy>::outputTabular (std::string& output)
|
||||
}
|
||||
|
||||
Color net_color;
|
||||
if (context.color () && net)
|
||||
if (Context::getContext ().color () && net)
|
||||
net_color = net > 0
|
||||
? Color (Color::red)
|
||||
: Color (Color::green);
|
||||
@@ -260,7 +258,7 @@ void CmdHistoryBase<HistoryStrategy>::outputTabular (std::string& output)
|
||||
row = view.addRow ();
|
||||
|
||||
Color row_color;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
row_color = Color (Color::nocolor, Color::nocolor, false, true, false);
|
||||
|
||||
view.set (row, HistoryStrategy::dateFieldCount - 1, "Average", row_color);
|
||||
@@ -277,7 +275,7 @@ void CmdHistoryBase<HistoryStrategy>::outputTabular (std::string& output)
|
||||
<< '\n';
|
||||
else
|
||||
{
|
||||
context.footnote ("No tasks.");
|
||||
Context::getContext ().footnote ("No tasks.");
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <main.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
std::string zshColonReplacement = ",";
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -72,7 +70,7 @@ int CmdIDs::execute (std::string& output)
|
||||
std::sort (ids.begin (), ids.end ());
|
||||
output = compressIds (ids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -166,7 +164,7 @@ int CmdCompletionIds::execute (std::string& output)
|
||||
std::sort (ids.begin (), ids.end ());
|
||||
output = join ("\n", ids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,7 +205,7 @@ int CmdZshCompletionIds::execute (std::string& output)
|
||||
|
||||
output = out.str ();
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -244,7 +242,7 @@ int CmdUUIDs::execute (std::string& output)
|
||||
std::sort (uuids.begin (), uuids.end ());
|
||||
output = join (" ", uuids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -281,7 +279,7 @@ int CmdCompletionUuids::execute (std::string& output)
|
||||
std::sort (uuids.begin (), uuids.end ());
|
||||
output = join ("\n", uuids) + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -320,7 +318,7 @@ int CmdZshCompletionUuids::execute (std::string& output)
|
||||
|
||||
output = out.str ();
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <shared.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdImport::CmdImport ()
|
||||
{
|
||||
@@ -58,7 +56,7 @@ int CmdImport::execute (std::string&)
|
||||
auto count = 0;
|
||||
|
||||
// Get filenames from command line arguments.
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (! words.size () ||
|
||||
(words.size () == 1 && words[0] == "-"))
|
||||
{
|
||||
@@ -91,7 +89,7 @@ int CmdImport::execute (std::string&)
|
||||
}
|
||||
}
|
||||
|
||||
context.footnote (format ("Imported {1} tasks.", count));
|
||||
Context::getContext ().footnote (format ("Imported {1} tasks.", count));
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -177,7 +175,7 @@ void CmdImport::importSingleTask (json::object* obj)
|
||||
|
||||
// Check whether the imported task is new or a modified existing task.
|
||||
Task before;
|
||||
if (context.tdb2.get (task.get ("uuid"), before))
|
||||
if (Context::getContext ().tdb2.get (task.get ("uuid"), before))
|
||||
{
|
||||
// We need to neglect updates from attributes with dynamic defaults
|
||||
// unless they have been explicitly specified on import.
|
||||
@@ -214,7 +212,7 @@ void CmdImport::importSingleTask (json::object* obj)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.tdb2.add (task);
|
||||
Context::getContext ().tdb2.add (task);
|
||||
std::cout << " add ";
|
||||
}
|
||||
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdInfo::CmdInfo ()
|
||||
{
|
||||
@@ -74,23 +72,23 @@ int CmdInfo::execute (std::string& output)
|
||||
|
||||
if (! filtered.size ())
|
||||
{
|
||||
context.footnote ("No matches.");
|
||||
Context::getContext ().footnote ("No matches.");
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
// Get the undo data.
|
||||
std::vector <std::string> undo;
|
||||
if (context.config.getBoolean ("journal.info"))
|
||||
undo = context.tdb2.undo.get_lines ();
|
||||
if (Context::getContext ().config.getBoolean ("journal.info"))
|
||||
undo = Context::getContext ().tdb2.undo.get_lines ();
|
||||
|
||||
// Determine the output date format, which uses a hierarchy of definitions.
|
||||
// rc.dateformat.info
|
||||
// rc.dateformat
|
||||
auto dateformat = context.config.get ("dateformat.info");
|
||||
auto dateformat = Context::getContext ().config.get ("dateformat.info");
|
||||
if (dateformat == "")
|
||||
dateformat = context.config.get ("dateformat");
|
||||
dateformat = Context::getContext ().config.get ("dateformat");
|
||||
|
||||
auto dateformatanno = context.config.get ("dateformat.annotation");
|
||||
auto dateformatanno = Context::getContext ().config.get ("dateformat.annotation");
|
||||
if (dateformatanno == "")
|
||||
dateformatanno = dateformat;
|
||||
|
||||
@@ -99,10 +97,10 @@ int CmdInfo::execute (std::string& output)
|
||||
for (auto& task : filtered)
|
||||
{
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
if (context.config.getBoolean ("obfuscate"))
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
if (Context::getContext ().config.getBoolean ("obfuscate"))
|
||||
view.obfuscate ();
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
view.forceColor ();
|
||||
view.add ("Name");
|
||||
view.add ("Value");
|
||||
@@ -121,7 +119,7 @@ int CmdInfo::execute (std::string& output)
|
||||
Color c;
|
||||
autoColorize (task, c);
|
||||
auto description = task.get ("description");
|
||||
auto indent = context.config.getInteger ("indent.annotation");
|
||||
auto indent = Context::getContext ().config.getInteger ("indent.annotation");
|
||||
|
||||
for (auto& anno : task.getAnnotations ())
|
||||
description += '\n'
|
||||
@@ -381,9 +379,9 @@ int CmdInfo::execute (std::string& output)
|
||||
std::string type;
|
||||
for (auto& att: all)
|
||||
{
|
||||
if (context.columns.find (att) != context.columns.end ())
|
||||
if (Context::getContext ().columns.find (att) != Context::getContext ().columns.end ())
|
||||
{
|
||||
Column* col = context.columns[att];
|
||||
Column* col = Context::getContext ().columns[att];
|
||||
if (col->is_uda ())
|
||||
{
|
||||
auto value = task.get (att);
|
||||
@@ -415,7 +413,7 @@ int CmdInfo::execute (std::string& output)
|
||||
for (auto& att : all)
|
||||
{
|
||||
if (att.substr (0, 11) != "annotation_" &&
|
||||
context.columns.find (att) == context.columns.end ())
|
||||
Context::getContext ().columns.find (att) == Context::getContext ().columns.end ())
|
||||
{
|
||||
row = view.addRow ();
|
||||
view.set (row, 0, '[' + att);
|
||||
@@ -428,19 +426,19 @@ int CmdInfo::execute (std::string& output)
|
||||
if (task.urgency () != 0.0)
|
||||
{
|
||||
setHeaderUnderline (urgencyDetails);
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
Color alternate (context.config.get ("color.alternate"));
|
||||
Color alternate (Context::getContext ().config.get ("color.alternate"));
|
||||
urgencyDetails.colorOdd (alternate);
|
||||
urgencyDetails.intraColorOdd (alternate);
|
||||
}
|
||||
|
||||
if (context.config.getBoolean ("obfuscate"))
|
||||
if (Context::getContext ().config.getBoolean ("obfuscate"))
|
||||
urgencyDetails.obfuscate ();
|
||||
if (context.config.getBoolean ("color"))
|
||||
if (Context::getContext ().config.getBoolean ("color"))
|
||||
view.forceColor ();
|
||||
|
||||
urgencyDetails.width (context.getWidth ());
|
||||
urgencyDetails.width (Context::getContext ().getWidth ());
|
||||
urgencyDetails.add (""); // Attribute
|
||||
urgencyDetails.add (""); // Value
|
||||
urgencyDetails.add (""); // *
|
||||
@@ -529,16 +527,16 @@ int CmdInfo::execute (std::string& output)
|
||||
Table journal;
|
||||
setHeaderUnderline (journal);
|
||||
|
||||
if (context.config.getBoolean ("obfuscate"))
|
||||
if (Context::getContext ().config.getBoolean ("obfuscate"))
|
||||
journal.obfuscate ();
|
||||
if (context.config.getBoolean ("color"))
|
||||
if (Context::getContext ().config.getBoolean ("color"))
|
||||
journal.forceColor ();
|
||||
|
||||
journal.width (context.getWidth ());
|
||||
journal.width (Context::getContext ().getWidth ());
|
||||
journal.add ("Date");
|
||||
journal.add ("Modification");
|
||||
|
||||
if (context.config.getBoolean ("journal.info") &&
|
||||
if (Context::getContext ().config.getBoolean ("journal.info") &&
|
||||
undo.size () > 3)
|
||||
{
|
||||
// Scan the undo data for entries matching this task, without making
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdLog::CmdLog ()
|
||||
{
|
||||
@@ -64,12 +62,12 @@ int CmdLog::execute (std::string& output)
|
||||
if (task.has ("wait"))
|
||||
throw std::string ("You cannot log waiting tasks.");
|
||||
|
||||
context.tdb2.add (task);
|
||||
Context::getContext ().tdb2.add (task);
|
||||
|
||||
if (context.verbose ("project"))
|
||||
context.footnote (onProjectChange (task));
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
Context::getContext ().footnote (onProjectChange (task));
|
||||
|
||||
if (context.verbose ("new-uuid"))
|
||||
if (Context::getContext ().verbose ("new-uuid"))
|
||||
output = format ("Logged task {1}.\n", task.get ("uuid"));
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include <Context.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdLogo::CmdLogo ()
|
||||
{
|
||||
@@ -83,10 +81,10 @@ int CmdLogo::execute (std::string& output)
|
||||
""
|
||||
};
|
||||
|
||||
if (! context.color ())
|
||||
if (! Context::getContext ().color ())
|
||||
throw std::string ("The logo command requires that color support is enabled.");
|
||||
|
||||
std::string indent (context.config.getInteger ("indent.report"), ' ');
|
||||
std::string indent (Context::getContext ().config.getInteger ("indent.report"), ' ');
|
||||
output += optionalBlankLine ();
|
||||
|
||||
for (int line = 0; data[line][0]; ++line)
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#define STRING_CMD_MODIFY_TASK_R "Modifying recurring task {1} '{2}'."
|
||||
#define STRING_CMD_MODIFY_RECUR "This is a recurring task. Do you want to modify all pending recurrences of this same task?"
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdModify::CmdModify ()
|
||||
{
|
||||
@@ -65,7 +63,7 @@ int CmdModify::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -104,7 +102,7 @@ int CmdModify::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (const auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Modified {1} task." : "Modified {1} tasks.", count);
|
||||
return rc;
|
||||
@@ -143,8 +141,8 @@ int CmdModify::modifyAndUpdate (
|
||||
updateRecurrenceMask (after);
|
||||
feedback_affected ("Modifying task {1} '{2}'.", after);
|
||||
feedback_unblocked (after);
|
||||
context.tdb2.modify (after);
|
||||
if (context.verbose ("project") && projectChanges)
|
||||
Context::getContext ().tdb2.modify (after);
|
||||
if (Context::getContext ().verbose ("project") && projectChanges)
|
||||
(*projectChanges)[after.get ("project")] = onProjectChange (before, after);
|
||||
|
||||
// Task has siblings - modify them.
|
||||
@@ -165,11 +163,11 @@ int CmdModify::modifyRecurrenceSiblings (
|
||||
{
|
||||
auto count = 0;
|
||||
|
||||
if ((context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if ((Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm (STRING_CMD_MODIFY_RECUR)) ||
|
||||
context.config.getBoolean ("recurrence.confirmation"))
|
||||
Context::getContext ().config.getBoolean ("recurrence.confirmation"))
|
||||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (task);
|
||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
Task alternate (sibling);
|
||||
@@ -178,16 +176,16 @@ int CmdModify::modifyRecurrenceSiblings (
|
||||
++count;
|
||||
feedback_affected (STRING_CMD_MODIFY_TASK_R, sibling);
|
||||
feedback_unblocked (sibling);
|
||||
context.tdb2.modify (sibling);
|
||||
if (context.verbose ("project") && projectChanges)
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
if (Context::getContext ().verbose ("project") && projectChanges)
|
||||
(*projectChanges)[sibling.get ("project")] = onProjectChange (alternate, sibling);
|
||||
}
|
||||
|
||||
// Modify the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task.get ("parent"), parent);
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
parent.modify (Task::modReplace);
|
||||
context.tdb2.modify (parent);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -200,9 +198,9 @@ int CmdModify::modifyRecurrenceParent (
|
||||
{
|
||||
auto count = 0;
|
||||
|
||||
auto children = context.tdb2.children (task);
|
||||
auto children = Context::getContext ().tdb2.children (task);
|
||||
if (children.size () &&
|
||||
(! context.config.getBoolean ("recurrence.confirmation") ||
|
||||
(! Context::getContext ().config.getBoolean ("recurrence.confirmation") ||
|
||||
confirm (STRING_CMD_MODIFY_RECUR)))
|
||||
{
|
||||
for (auto& child : children)
|
||||
@@ -210,8 +208,8 @@ int CmdModify::modifyRecurrenceParent (
|
||||
Task alternate (child);
|
||||
child.modify (Task::modReplace);
|
||||
updateRecurrenceMask (child);
|
||||
context.tdb2.modify (child);
|
||||
if (context.verbose ("project") && projectChanges)
|
||||
Context::getContext ().tdb2.modify (child);
|
||||
if (Context::getContext ().verbose ("project") && projectChanges)
|
||||
(*projectChanges)[child.get ("project")] = onProjectChange (alternate, child);
|
||||
++count;
|
||||
feedback_affected (STRING_CMD_MODIFY_TASK_R, child);
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <format.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdPrepend::CmdPrepend ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdPrepend::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -85,33 +83,33 @@ int CmdPrepend::execute (std::string&)
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Prepending to task {1} '{2}'.", task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
|
||||
// Prepend to siblings.
|
||||
if (task.has ("parent"))
|
||||
{
|
||||
if ((context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if ((Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm ("This is a recurring task. Do you want to prepend to all pending recurrences of this same task?")) ||
|
||||
context.config.getBoolean ("recurrence.confirmation"))
|
||||
Context::getContext ().config.getBoolean ("recurrence.confirmation"))
|
||||
{
|
||||
std::vector <Task> siblings = context.tdb2.siblings (task);
|
||||
std::vector <Task> siblings = Context::getContext ().tdb2.siblings (task);
|
||||
for (auto& sibling : siblings)
|
||||
{
|
||||
sibling.modify (Task::modPrepend, true);
|
||||
context.tdb2.modify (sibling);
|
||||
Context::getContext ().tdb2.modify (sibling);
|
||||
++count;
|
||||
feedback_affected ("Prepending to recurring task {1} '{2}'.", sibling);
|
||||
}
|
||||
|
||||
// Prepend to the parent
|
||||
Task parent;
|
||||
context.tdb2.get (task.get ("parent"), parent);
|
||||
Context::getContext ().tdb2.get (task.get ("parent"), parent);
|
||||
parent.modify (Task::modPrepend, true);
|
||||
context.tdb2.modify (parent);
|
||||
Context::getContext ().tdb2.modify (parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,7 +125,7 @@ int CmdPrepend::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Prepended {1} task." : "Prepended {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdProjects::CmdProjects ()
|
||||
{
|
||||
@@ -61,10 +59,10 @@ int CmdProjects::execute (std::string& output)
|
||||
// Get all the tasks.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
auto tasks = context.tdb2.pending.get_tasks ();
|
||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
if (context.config.getBoolean ("list.all.projects"))
|
||||
for (auto& task : context.tdb2.completed.get_tasks ())
|
||||
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
||||
tasks.push_back (task);
|
||||
|
||||
// Apply the filter.
|
||||
@@ -106,7 +104,7 @@ int CmdProjects::execute (std::string& output)
|
||||
{
|
||||
// Render a list of project names from the map.
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("Project");
|
||||
view.add ("Tasks", false);
|
||||
setHeaderUnderline (view);
|
||||
@@ -180,10 +178,10 @@ int CmdCompletionProjects::execute (std::string& output)
|
||||
// Get all the tasks.
|
||||
handleUntil ();
|
||||
handleRecurrence ();
|
||||
auto tasks = context.tdb2.pending.get_tasks ();
|
||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
if (context.config.getBoolean ("list.all.projects"))
|
||||
for (auto& task : context.tdb2.completed.get_tasks ())
|
||||
if (Context::getContext ().config.getBoolean ("list.all.projects"))
|
||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
||||
tasks.push_back (task);
|
||||
|
||||
// Apply the filter.
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <format.h>
|
||||
#include <shared.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdPurge::CmdPurge ()
|
||||
{
|
||||
@@ -57,7 +55,7 @@ CmdPurge::CmdPurge ()
|
||||
// - child tasks
|
||||
void CmdPurge::purgeTask (Task& task, int& count)
|
||||
{
|
||||
context.tdb2.purge (task);
|
||||
Context::getContext ().tdb2.purge (task);
|
||||
handleDeps (task);
|
||||
handleChildren (task, count);
|
||||
count++;
|
||||
@@ -70,14 +68,14 @@ void CmdPurge::handleDeps (Task& task)
|
||||
{
|
||||
std::string uuid = task.get ("uuid");
|
||||
|
||||
for (auto& blockedConst: context.tdb2.all_tasks ())
|
||||
for (auto& blockedConst: Context::getContext ().tdb2.all_tasks ())
|
||||
{
|
||||
Task& blocked = const_cast<Task&>(blockedConst);
|
||||
if (blocked.has ("depends") &&
|
||||
blocked.get ("depends").find (uuid) != std::string::npos)
|
||||
{
|
||||
blocked.removeDependency (uuid);
|
||||
context.tdb2.modify (blocked);
|
||||
Context::getContext ().tdb2.modify (blocked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -95,7 +93,7 @@ void CmdPurge::handleChildren (Task& task, int& count)
|
||||
std::vector<Task> children;
|
||||
|
||||
// Find all child tasks
|
||||
for (auto& childConst: context.tdb2.all_tasks ())
|
||||
for (auto& childConst: Context::getContext ().tdb2.all_tasks ())
|
||||
{
|
||||
Task& child = const_cast<Task&> (childConst);
|
||||
|
||||
@@ -120,8 +118,8 @@ void CmdPurge::handleChildren (Task& task, int& count)
|
||||
task.get ("description"),
|
||||
children.size ());
|
||||
|
||||
if (context.config.getBoolean ("recurrence.confirmation") ||
|
||||
(context.config.get ("recurrence.confirmation") == "prompt"
|
||||
if (Context::getContext ().config.getBoolean ("recurrence.confirmation") ||
|
||||
(Context::getContext ().config.get ("recurrence.confirmation") == "prompt"
|
||||
&& confirm (question)))
|
||||
{
|
||||
for (auto& child: children)
|
||||
@@ -145,7 +143,7 @@ int CmdPurge::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdReports::CmdReports ()
|
||||
{
|
||||
@@ -56,7 +54,7 @@ int CmdReports::execute (std::string& output)
|
||||
std::vector <std::string> reports;
|
||||
|
||||
// Add custom reports.
|
||||
for (auto& i : context.config)
|
||||
for (auto& i : Context::getContext ().config)
|
||||
{
|
||||
if (i.first.substr (0, 7) == "report.")
|
||||
{
|
||||
@@ -85,7 +83,7 @@ int CmdReports::execute (std::string& output)
|
||||
// Compose the output.
|
||||
std::stringstream out;
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("Report");
|
||||
view.add ("Description");
|
||||
setHeaderUnderline (view);
|
||||
@@ -94,7 +92,7 @@ int CmdReports::execute (std::string& output)
|
||||
{
|
||||
int row = view.addRow ();
|
||||
view.set (row, 0, report);
|
||||
view.set (row, 1, context.commands[report]->description ());
|
||||
view.set (row, 1, Context::getContext ().commands[report]->description ());
|
||||
}
|
||||
|
||||
out << optionalBlankLine ()
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
#define STRING_CMD_SHOW_DIFFER_COLOR "These are highlighted in {1} above."
|
||||
#define STRING_CMD_SHOW_CONFIG_ERROR "Configuration error: {1} contains an unrecognized value '{2}'."
|
||||
|
||||
extern Context context;
|
||||
extern std::string configurationDefaults;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -66,11 +65,11 @@ int CmdShow::execute (std::string& output)
|
||||
|
||||
// Obtain the arguments from the description. That way, things like '--'
|
||||
// have already been handled.
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::vector <std::string> words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () > 1)
|
||||
throw std::string ("You can only specify 'all' or a search string.");
|
||||
|
||||
int width = context.getWidth ();
|
||||
int width = Context::getContext ().getWidth ();
|
||||
|
||||
// Complain about configuration variables that are not recognized.
|
||||
// These are the regular configuration variables.
|
||||
@@ -224,7 +223,7 @@ int CmdShow::execute (std::string& output)
|
||||
recognized += "_forcecolor ";
|
||||
|
||||
std::vector <std::string> unrecognized;
|
||||
for (auto& i : context.config)
|
||||
for (auto& i : Context::getContext ().config)
|
||||
{
|
||||
// Disallow partial matches by tacking a leading and trailing space on each
|
||||
// variable name.
|
||||
@@ -259,7 +258,7 @@ int CmdShow::execute (std::string& output)
|
||||
Configuration default_config;
|
||||
default_config.parse (configurationDefaults);
|
||||
|
||||
for (auto& i : context.config)
|
||||
for (auto& i : Context::getContext ().config)
|
||||
if (i.second != default_config.get (i.first))
|
||||
default_values.push_back (i.first);
|
||||
|
||||
@@ -272,10 +271,10 @@ int CmdShow::execute (std::string& output)
|
||||
|
||||
Color error;
|
||||
Color warning;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
error = Color (context.config.get ("color.error"));
|
||||
warning = Color (context.config.get ("color.warning"));
|
||||
error = Color (Context::getContext ().config.get ("color.error"));
|
||||
warning = Color (Context::getContext ().config.get ("color.warning"));
|
||||
}
|
||||
|
||||
bool issue_error = false;
|
||||
@@ -291,7 +290,7 @@ int CmdShow::execute (std::string& output)
|
||||
section = "";
|
||||
|
||||
std::string::size_type loc;
|
||||
for (auto& i : context.config)
|
||||
for (auto& i : Context::getContext ().config)
|
||||
{
|
||||
loc = i.first.find (section, 0);
|
||||
if (loc != std::string::npos)
|
||||
@@ -333,7 +332,7 @@ int CmdShow::execute (std::string& output)
|
||||
{
|
||||
out << "Some of your .taskrc variables differ from the default values.\n";
|
||||
|
||||
if (context.color () && warning.nontrivial ())
|
||||
if (Context::getContext ().color () && warning.nontrivial ())
|
||||
out << " "
|
||||
<< format (STRING_CMD_SHOW_DIFFER_COLOR, warning.colorize ("color"))
|
||||
<< "\n\n";
|
||||
@@ -347,7 +346,7 @@ int CmdShow::execute (std::string& output)
|
||||
for (auto& i : unrecognized)
|
||||
out << " " << i << '\n';
|
||||
|
||||
if (context.color () && error.nontrivial ())
|
||||
if (Context::getContext ().color () && error.nontrivial ())
|
||||
out << '\n' << format (STRING_CMD_SHOW_DIFFER_COLOR, error.colorize ("color"));
|
||||
|
||||
out << "\n\n";
|
||||
@@ -360,7 +359,7 @@ int CmdShow::execute (std::string& output)
|
||||
// TODO Check for referenced but missing string files.
|
||||
|
||||
// Check for bad values in rc.calendar.details.
|
||||
std::string calendardetails = context.config.get ("calendar.details");
|
||||
std::string calendardetails = Context::getContext ().config.get ("calendar.details");
|
||||
if (calendardetails != "full" &&
|
||||
calendardetails != "sparse" &&
|
||||
calendardetails != "none")
|
||||
@@ -368,7 +367,7 @@ int CmdShow::execute (std::string& output)
|
||||
<< '\n';
|
||||
|
||||
// Check for bad values in rc.calendar.holidays.
|
||||
std::string calendarholidays = context.config.get ("calendar.holidays");
|
||||
std::string calendarholidays = Context::getContext ().config.get ("calendar.holidays");
|
||||
if (calendarholidays != "full" &&
|
||||
calendarholidays != "sparse" &&
|
||||
calendarholidays != "none")
|
||||
@@ -378,14 +377,14 @@ int CmdShow::execute (std::string& output)
|
||||
// Verify installation. This is mentioned in the documentation as the way
|
||||
// to ensure everything is properly installed.
|
||||
|
||||
if (context.config.size () == 0)
|
||||
if (Context::getContext ().config.size () == 0)
|
||||
{
|
||||
out << "Configuration error: .taskrc contains no entries.\n";
|
||||
rc = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Directory location (context.config.get ("data.location"));
|
||||
Directory location (Context::getContext ().config.get ("data.location"));
|
||||
|
||||
if (location._data == "")
|
||||
out << "Configuration error: data.location not specified in .taskrc file.\n";
|
||||
@@ -413,13 +412,13 @@ CmdShowRaw::CmdShowRaw ()
|
||||
int CmdShowRaw::execute (std::string& output)
|
||||
{
|
||||
// Get all the settings and sort alphabetically by name.
|
||||
auto all = context.config.all ();
|
||||
auto all = Context::getContext ().config.all ();
|
||||
std::sort (all.begin (), all.end ());
|
||||
|
||||
// Display them all.
|
||||
std::stringstream out;
|
||||
for (auto& i : all)
|
||||
out << i << '=' << context.config.get (i) << '\n';
|
||||
out << i << '=' << Context::getContext ().config.get (i) << '\n';
|
||||
|
||||
output = out.str ();
|
||||
return 0;
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdStart::CmdStart ()
|
||||
{
|
||||
@@ -63,7 +61,7 @@ int CmdStart::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -91,19 +89,19 @@ int CmdStart::execute (std::string&)
|
||||
task.setStatus (Task::pending);
|
||||
}
|
||||
|
||||
if (context.config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (context.config.get ("journal.time.start.annotation"));
|
||||
if (Context::getContext ().config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (Context::getContext ().config.get ("journal.time.start.annotation"));
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
updateRecurrenceMask (task);
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Starting task {1} '{2}'.", task);
|
||||
if (!nagged)
|
||||
nagged = nag (task);
|
||||
dependencyChainOnStart (task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
}
|
||||
else
|
||||
@@ -127,7 +125,7 @@ int CmdStart::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Started {1} task." : "Started {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdStats::CmdStats ()
|
||||
{
|
||||
@@ -62,23 +60,23 @@ int CmdStats::execute (std::string& output)
|
||||
int rc = 0;
|
||||
std::stringstream out;
|
||||
|
||||
std::string dateformat = context.config.get ("dateformat");
|
||||
std::string dateformat = Context::getContext ().config.get ("dateformat");
|
||||
|
||||
// Go get the file sizes.
|
||||
size_t dataSize = context.tdb2.pending._file.size ()
|
||||
+ context.tdb2.completed._file.size ()
|
||||
+ context.tdb2.undo._file.size ()
|
||||
+ context.tdb2.backlog._file.size ();
|
||||
size_t dataSize = Context::getContext ().tdb2.pending._file.size ()
|
||||
+ Context::getContext ().tdb2.completed._file.size ()
|
||||
+ Context::getContext ().tdb2.undo._file.size ()
|
||||
+ Context::getContext ().tdb2.backlog._file.size ();
|
||||
|
||||
// Count the undo transactions.
|
||||
std::vector <std::string> undoTxns = context.tdb2.undo.get_lines ();
|
||||
std::vector <std::string> undoTxns = Context::getContext ().tdb2.undo.get_lines ();
|
||||
int undoCount = 0;
|
||||
for (auto& tx : undoTxns)
|
||||
if (tx == "---")
|
||||
++undoCount;
|
||||
|
||||
// Count the backlog transactions.
|
||||
std::vector <std::string> backlogTxns = context.tdb2.backlog.get_lines ();
|
||||
std::vector <std::string> backlogTxns = Context::getContext ().tdb2.backlog.get_lines ();
|
||||
int backlogCount = 0;
|
||||
for (auto& tx : backlogTxns)
|
||||
if (tx[0] == '{')
|
||||
@@ -86,7 +84,7 @@ int CmdStats::execute (std::string& output)
|
||||
|
||||
// Get all the tasks.
|
||||
Filter filter;
|
||||
std::vector <Task> all = context.tdb2.all_tasks ();
|
||||
std::vector <Task> all = Context::getContext ().tdb2.all_tasks ();
|
||||
std::vector <Task> filtered;
|
||||
filter.subset (all, filtered);
|
||||
|
||||
@@ -155,7 +153,7 @@ int CmdStats::execute (std::string& output)
|
||||
|
||||
// Create a table for output.
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.intraPadding (2);
|
||||
view.add ("Category");
|
||||
view.add ("Data");
|
||||
@@ -280,9 +278,9 @@ int CmdStats::execute (std::string& output)
|
||||
}
|
||||
|
||||
// If an alternating row color is specified, notify the table.
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
Color alternate (context.config.get ("color.alternate"));
|
||||
Color alternate (Context::getContext ().config.get ("color.alternate"));
|
||||
if (alternate.nontrivial ())
|
||||
{
|
||||
view.colorOdd (alternate);
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <main.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdStop::CmdStop ()
|
||||
{
|
||||
@@ -62,7 +60,7 @@ int CmdStop::execute (std::string&)
|
||||
filter.subset (filtered);
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -83,17 +81,17 @@ int CmdStop::execute (std::string&)
|
||||
task.modify (Task::modAnnotate);
|
||||
task.remove ("start");
|
||||
|
||||
if (context.config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (context.config.get ("journal.time.stop.annotation"));
|
||||
if (Context::getContext ().config.getBoolean ("journal.time"))
|
||||
task.addAnnotation (Context::getContext ().config.get ("journal.time.stop.annotation"));
|
||||
|
||||
if (permission (taskDifferences (before, task) + question, filtered.size ()))
|
||||
{
|
||||
updateRecurrenceMask (task);
|
||||
context.tdb2.modify (task);
|
||||
Context::getContext ().tdb2.modify (task);
|
||||
++count;
|
||||
feedback_affected ("Stopping task {1} '{2}'.", task);
|
||||
dependencyChainOnStart (task);
|
||||
if (context.verbose ("project"))
|
||||
if (Context::getContext ().verbose ("project"))
|
||||
projectChanges[task.get ("project")] = onProjectChange (task, false);
|
||||
}
|
||||
else
|
||||
@@ -117,7 +115,7 @@ int CmdStop::execute (std::string&)
|
||||
// Now list the project changes.
|
||||
for (auto& change : projectChanges)
|
||||
if (change.first != "")
|
||||
context.footnote (change.second);
|
||||
Context::getContext ().footnote (change.second);
|
||||
|
||||
feedback_affected (count == 1 ? "Stopped {1} task." : "Stopped {1} tasks.", count);
|
||||
return rc;
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include <util.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdSummary::CmdSummary ()
|
||||
{
|
||||
@@ -62,7 +60,7 @@ CmdSummary::CmdSummary ()
|
||||
int CmdSummary::execute (std::string& output)
|
||||
{
|
||||
int rc = 0;
|
||||
bool showAllProjects = context.config.getBoolean ("summary.all.projects");
|
||||
bool showAllProjects = Context::getContext ().config.getBoolean ("summary.all.projects");
|
||||
|
||||
// Apply filter.
|
||||
handleUntil ();
|
||||
@@ -132,7 +130,7 @@ int CmdSummary::execute (std::string& output)
|
||||
|
||||
// Create a table for output.
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("Project");
|
||||
view.add ("Remaining", false);
|
||||
view.add ("Avg age", false);
|
||||
@@ -142,10 +140,10 @@ int CmdSummary::execute (std::string& output)
|
||||
|
||||
Color bar_color;
|
||||
Color bg_color;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
bar_color = Color (context.config.get ("color.summary.bar"));
|
||||
bg_color = Color (context.config.get ("color.summary.background"));
|
||||
bar_color = Color (Context::getContext ().config.get ("color.summary.bar"));
|
||||
bg_color = Color (Context::getContext ().config.get ("color.summary.background"));
|
||||
}
|
||||
|
||||
int barWidth = 30;
|
||||
@@ -183,7 +181,7 @@ int CmdSummary::execute (std::string& output)
|
||||
|
||||
std::string bar;
|
||||
std::string subbar;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
bar += bar_color.colorize (std::string ( completedBar, ' '));
|
||||
bar += bg_color.colorize (std::string (barWidth - completedBar, ' '));
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdSync::CmdSync ()
|
||||
{
|
||||
@@ -67,12 +65,12 @@ int CmdSync::execute (std::string& output)
|
||||
|
||||
// Loog for the 'init' keyword to indicate one-time pending.data upload.
|
||||
bool first_time_init = false;
|
||||
std::vector <std::string> words = context.cli2.getWords ();
|
||||
std::vector <std::string> words = Context::getContext ().cli2.getWords ();
|
||||
for (auto& word : words)
|
||||
{
|
||||
if (closeEnough ("initialize", word, 4))
|
||||
{
|
||||
if (!context.config.getBoolean ("confirmation") ||
|
||||
if (!Context::getContext ().config.getBoolean ("confirmation") ||
|
||||
confirm ("Please confirm that you wish to upload all your tasks to the Taskserver"))
|
||||
first_time_init = true;
|
||||
else
|
||||
@@ -81,13 +79,13 @@ int CmdSync::execute (std::string& output)
|
||||
}
|
||||
|
||||
// If no server is set up, quit.
|
||||
std::string connection = context.config.get ("taskd.server");
|
||||
std::string connection = Context::getContext ().config.get ("taskd.server");
|
||||
if (connection == "" ||
|
||||
connection.rfind (':') == std::string::npos)
|
||||
throw std::string ("Taskserver is not configured.");
|
||||
|
||||
// Obtain credentials.
|
||||
std::string credentials_string = context.config.get ("taskd.credentials");
|
||||
std::string credentials_string = Context::getContext ().config.get ("taskd.credentials");
|
||||
if (credentials_string == "")
|
||||
throw std::string ("Taskserver credentials malformed.");
|
||||
|
||||
@@ -96,7 +94,7 @@ int CmdSync::execute (std::string& output)
|
||||
throw std::string ("Taskserver credentials malformed.");
|
||||
|
||||
// This was a Boolean value in 2.3.0, and is a tri-state since 2.4.0.
|
||||
std::string trust_value = context.config.get ("taskd.trust");
|
||||
std::string trust_value = Context::getContext ().config.get ("taskd.trust");
|
||||
if (trust_value != "strict" &&
|
||||
trust_value != "ignore hostname" &&
|
||||
trust_value != "allow all")
|
||||
@@ -109,18 +107,18 @@ int CmdSync::execute (std::string& output)
|
||||
trust = TLSClient::ignore_hostname;
|
||||
|
||||
// CA must exist, if provided.
|
||||
File ca (context.config.get ("taskd.ca"));
|
||||
File ca (Context::getContext ().config.get ("taskd.ca"));
|
||||
if (ca._data != "" && ! ca.exists ())
|
||||
throw std::string ("CA certificate not found.");
|
||||
|
||||
if (trust == TLSClient::allow_all && ca._data != "")
|
||||
throw std::string ("You should either provide a CA certificate or override verification, but not both.");
|
||||
|
||||
File certificate (context.config.get ("taskd.certificate"));
|
||||
File certificate (Context::getContext ().config.get ("taskd.certificate"));
|
||||
if (! certificate.exists ())
|
||||
throw std::string ("Taskserver certificate missing.");
|
||||
|
||||
File key (context.config.get ("taskd.key"));
|
||||
File key (Context::getContext ().config.get ("taskd.key"));
|
||||
if (! key.exists ())
|
||||
throw std::string ("Taskserver key missing.");
|
||||
|
||||
@@ -132,9 +130,9 @@ int CmdSync::execute (std::string& output)
|
||||
{
|
||||
// Delete backlog.data. Because if we're uploading everything, the list of
|
||||
// deltas is meaningless.
|
||||
context.tdb2.backlog._file.truncate ();
|
||||
Context::getContext ().tdb2.backlog._file.truncate ();
|
||||
|
||||
auto all_tasks = context.tdb2.all_tasks ();
|
||||
auto all_tasks = Context::getContext ().tdb2.all_tasks ();
|
||||
for (auto& i : all_tasks)
|
||||
{
|
||||
payload += i.composeJSON () + '\n';
|
||||
@@ -143,7 +141,7 @@ int CmdSync::execute (std::string& output)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector <std::string> lines = context.tdb2.backlog.get_lines ();
|
||||
std::vector <std::string> lines = Context::getContext ().tdb2.backlog.get_lines ();
|
||||
for (auto& i : lines)
|
||||
{
|
||||
if (i[0] == '{')
|
||||
@@ -169,7 +167,7 @@ int CmdSync::execute (std::string& output)
|
||||
|
||||
request.setPayload (payload);
|
||||
|
||||
if (context.verbose ("sync"))
|
||||
if (Context::getContext ().verbose ("sync"))
|
||||
out << format ("Syncing with {1}", connection)
|
||||
<< '\n';
|
||||
|
||||
@@ -189,10 +187,10 @@ int CmdSync::execute (std::string& output)
|
||||
{
|
||||
Color colorAdded;
|
||||
Color colorChanged;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
{
|
||||
colorAdded = Color (context.config.get ("color.sync.added"));
|
||||
colorChanged = Color (context.config.get ("color.sync.changed"));
|
||||
colorAdded = Color (Context::getContext ().config.get ("color.sync.added"));
|
||||
colorChanged = Color (Context::getContext ().config.get ("color.sync.changed"));
|
||||
}
|
||||
|
||||
int download_count = 0;
|
||||
@@ -203,7 +201,7 @@ int CmdSync::execute (std::string& output)
|
||||
// the payload, so if there are two or more lines, then we have merging
|
||||
// to perform, otherwise it's just a backlog.data update.
|
||||
if (lines.size () > 1)
|
||||
context.tdb2.all_tasks ();
|
||||
Context::getContext ().tdb2.all_tasks ();
|
||||
|
||||
std::string sync_key = "";
|
||||
for (auto& line : lines)
|
||||
@@ -217,33 +215,33 @@ int CmdSync::execute (std::string& output)
|
||||
|
||||
// Is it a new task from the server, or an update to an existing one?
|
||||
Task dummy;
|
||||
if (context.tdb2.get (uuid, dummy))
|
||||
if (Context::getContext ().tdb2.get (uuid, dummy))
|
||||
{
|
||||
if (context.verbose ("sync"))
|
||||
if (Context::getContext ().verbose ("sync"))
|
||||
out << " "
|
||||
<< colorChanged.colorize (
|
||||
format ("modify {1} '{2}'",
|
||||
uuid,
|
||||
from_server.get ("description")))
|
||||
<< '\n';
|
||||
context.tdb2.modify (from_server, false);
|
||||
Context::getContext ().tdb2.modify (from_server, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (context.verbose ("sync"))
|
||||
if (Context::getContext ().verbose ("sync"))
|
||||
out << " "
|
||||
<< colorAdded.colorize (
|
||||
format (" add {1} '{2}'",
|
||||
uuid,
|
||||
from_server.get ("description")))
|
||||
<< '\n';
|
||||
context.tdb2.add (from_server, false);
|
||||
Context::getContext ().tdb2.add (from_server, false);
|
||||
}
|
||||
}
|
||||
else if (line != "")
|
||||
{
|
||||
sync_key = line;
|
||||
context.debug ("Sync key " + sync_key);
|
||||
Context::getContext ().debug ("Sync key " + sync_key);
|
||||
}
|
||||
|
||||
// Otherwise line is blank, so ignore it.
|
||||
@@ -254,46 +252,46 @@ int CmdSync::execute (std::string& output)
|
||||
if (sync_key != "")
|
||||
{
|
||||
// Truncate backlog.data, save new sync_key.
|
||||
context.tdb2.backlog._file.truncate ();
|
||||
context.tdb2.backlog.clear_tasks ();
|
||||
context.tdb2.backlog.clear_lines ();
|
||||
context.tdb2.backlog.add_line (sync_key + '\n');
|
||||
Context::getContext ().tdb2.backlog._file.truncate ();
|
||||
Context::getContext ().tdb2.backlog.clear_tasks ();
|
||||
Context::getContext ().tdb2.backlog.clear_lines ();
|
||||
Context::getContext ().tdb2.backlog.add_line (sync_key + '\n');
|
||||
|
||||
// Present a clear status message.
|
||||
if (upload_count == 0 && download_count == 0)
|
||||
// Note: should not happen - expect code 201 instead.
|
||||
context.footnote ("Sync successful.");
|
||||
Context::getContext ().footnote ("Sync successful.");
|
||||
else if (upload_count == 0 && download_count > 0)
|
||||
context.footnote (format ("Sync successful. {1} changes downloaded.", download_count));
|
||||
Context::getContext ().footnote (format ("Sync successful. {1} changes downloaded.", download_count));
|
||||
else if (upload_count > 0 && download_count == 0)
|
||||
context.footnote (format ("Sync successful. {1} changes uploaded.", upload_count));
|
||||
Context::getContext ().footnote (format ("Sync successful. {1} changes uploaded.", upload_count));
|
||||
else if (upload_count > 0 && download_count > 0)
|
||||
context.footnote (format ("Sync successful. {1} changes uploaded, {2} changes downloaded.", upload_count, download_count));
|
||||
Context::getContext ().footnote (format ("Sync successful. {1} changes uploaded, {2} changes downloaded.", upload_count, download_count));
|
||||
}
|
||||
|
||||
status = 0;
|
||||
}
|
||||
else if (code == "201")
|
||||
{
|
||||
context.footnote ("Sync successful. No changes.");
|
||||
Context::getContext ().footnote ("Sync successful. No changes.");
|
||||
status = 0;
|
||||
}
|
||||
else if (code == "301")
|
||||
{
|
||||
std::string new_server = response.get ("info");
|
||||
context.config.set ("taskd.server", new_server);
|
||||
context.error ("The server account has been relocated. Please update your configuration using:");
|
||||
context.error (" " + format ("task config taskd.server {1}", new_server));
|
||||
Context::getContext ().config.set ("taskd.server", new_server);
|
||||
Context::getContext ().error ("The server account has been relocated. Please update your configuration using:");
|
||||
Context::getContext ().error (" " + format ("task config taskd.server {1}", new_server));
|
||||
status = 2;
|
||||
}
|
||||
else if (code == "430")
|
||||
{
|
||||
context.error ("Sync failed. Either your credentials are incorrect, or your account doesn't exist on the Taskserver.");
|
||||
Context::getContext ().error ("Sync failed. Either your credentials are incorrect, or your account doesn't exist on the Taskserver.");
|
||||
status = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.error (format ("Sync failed. The Taskserver returned error: {1} {2}",
|
||||
Context::getContext ().error (format ("Sync failed. The Taskserver returned error: {1} {2}",
|
||||
code,
|
||||
response.get ("status")));
|
||||
status = 2;
|
||||
@@ -303,10 +301,10 @@ int CmdSync::execute (std::string& output)
|
||||
std::string to_be_displayed = response.get ("messages");
|
||||
if (to_be_displayed != "")
|
||||
{
|
||||
if (context.verbose ("footnote"))
|
||||
context.footnote (to_be_displayed);
|
||||
if (Context::getContext ().verbose ("footnote"))
|
||||
Context::getContext ().footnote (to_be_displayed);
|
||||
else
|
||||
context.debug (to_be_displayed);
|
||||
Context::getContext ().debug (to_be_displayed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,11 +317,11 @@ int CmdSync::execute (std::string& output)
|
||||
// - No signal/cable
|
||||
else
|
||||
{
|
||||
context.error ("Sync failed. Could not connect to the Taskserver.");
|
||||
Context::getContext ().error ("Sync failed. Could not connect to the Taskserver.");
|
||||
status = 1;
|
||||
}
|
||||
|
||||
if (context.verbose ("sync"))
|
||||
if (Context::getContext ().verbose ("sync"))
|
||||
out << '\n';
|
||||
output = out.str ();
|
||||
|
||||
@@ -365,10 +363,10 @@ bool CmdSync::send (
|
||||
try
|
||||
{
|
||||
TLSClient client;
|
||||
client.debug (context.config.getInteger ("debug.tls"));
|
||||
client.debug (Context::getContext ().config.getInteger ("debug.tls"));
|
||||
|
||||
client.trust (trust);
|
||||
client.ciphers (context.config.get ("taskd.ciphers"));
|
||||
client.ciphers (Context::getContext ().config.get ("taskd.ciphers"));
|
||||
client.init (ca, certificate, key);
|
||||
client.connect (server, port);
|
||||
client.send (request.serialize () + '\n');
|
||||
@@ -383,7 +381,7 @@ bool CmdSync::send (
|
||||
|
||||
catch (std::string& error)
|
||||
{
|
||||
context.error (error);
|
||||
Context::getContext ().error (error);
|
||||
}
|
||||
|
||||
// Indicate message failed.
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#include <format.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdTags::CmdTags ()
|
||||
{
|
||||
@@ -60,10 +58,10 @@ int CmdTags::execute (std::string& output)
|
||||
std::stringstream out;
|
||||
|
||||
// Get all the tasks.
|
||||
auto tasks = context.tdb2.pending.get_tasks ();
|
||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
if (context.config.getBoolean ("list.all.tags"))
|
||||
for (auto& task : context.tdb2.completed.get_tasks ())
|
||||
if (Context::getContext ().config.getBoolean ("list.all.tags"))
|
||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
||||
tasks.push_back (task);
|
||||
|
||||
int quantity = tasks.size ();
|
||||
@@ -89,20 +87,20 @@ int CmdTags::execute (std::string& output)
|
||||
{
|
||||
// Render a list of tags names from the map.
|
||||
Table view;
|
||||
view.width (context.getWidth ());
|
||||
view.width (Context::getContext ().getWidth ());
|
||||
view.add ("Tag");
|
||||
view.add ("Count", false);
|
||||
setHeaderUnderline (view);
|
||||
|
||||
Color bold;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
bold = Color ("bold");
|
||||
|
||||
bool special = false;
|
||||
for (auto& i : unique)
|
||||
{
|
||||
// Highlight the special tags.
|
||||
special = (context.color () &&
|
||||
special = (Context::getContext ().color () &&
|
||||
(i.first == "nocolor" ||
|
||||
i.first == "nonag" ||
|
||||
i.first == "nocal" ||
|
||||
@@ -118,20 +116,20 @@ int CmdTags::execute (std::string& output)
|
||||
<< optionalBlankLine ();
|
||||
|
||||
if (unique.size () == 1)
|
||||
context.footnote ("1 tag");
|
||||
Context::getContext ().footnote ("1 tag");
|
||||
else
|
||||
context.footnote (format ("{1} tags", unique.size ()));
|
||||
Context::getContext ().footnote (format ("{1} tags", unique.size ()));
|
||||
|
||||
if (quantity == 1)
|
||||
context.footnote ("(1 task)");
|
||||
Context::getContext ().footnote ("(1 task)");
|
||||
else
|
||||
context.footnote (format ("({1} tasks)", quantity));
|
||||
Context::getContext ().footnote (format ("({1} tasks)", quantity));
|
||||
|
||||
out << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
context.footnote ("No tags.");
|
||||
Context::getContext ().footnote ("No tags.");
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
@@ -159,10 +157,10 @@ CmdCompletionTags::CmdCompletionTags ()
|
||||
int CmdCompletionTags::execute (std::string& output)
|
||||
{
|
||||
// Get all the tasks.
|
||||
auto tasks = context.tdb2.pending.get_tasks ();
|
||||
auto tasks = Context::getContext ().tdb2.pending.get_tasks ();
|
||||
|
||||
if (context.config.getBoolean ("complete.all.tags"))
|
||||
for (auto& task : context.tdb2.completed.get_tasks ())
|
||||
if (Context::getContext ().config.getBoolean ("complete.all.tags"))
|
||||
for (auto& task : Context::getContext ().tdb2.completed.get_tasks ())
|
||||
tasks.push_back (task);
|
||||
|
||||
// Apply filter.
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include <util.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdTimesheet::CmdTimesheet ()
|
||||
{
|
||||
@@ -62,7 +60,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||
|
||||
// Detect a filter.
|
||||
bool hasFilter {false};
|
||||
for (auto& a : context.cli2._args)
|
||||
for (auto& a : Context::getContext ().cli2._args)
|
||||
{
|
||||
if (a.hasTag ("FILTER"))
|
||||
{
|
||||
@@ -73,10 +71,10 @@ int CmdTimesheet::execute (std::string& output)
|
||||
|
||||
if (! hasFilter)
|
||||
{
|
||||
auto defaultFilter = context.config.get ("report.timesheet.filter");
|
||||
auto defaultFilter = Context::getContext ().config.get ("report.timesheet.filter");
|
||||
if (defaultFilter == "")
|
||||
defaultFilter = "(+PENDING and start.after:now-4wks) or (+COMPLETED and end.after:now-4wks)";
|
||||
context.cli2.addFilter (defaultFilter);
|
||||
Context::getContext ().cli2.addFilter (defaultFilter);
|
||||
}
|
||||
|
||||
// Apply filter to get a set of tasks.
|
||||
@@ -115,8 +113,8 @@ int CmdTimesheet::execute (std::string& output)
|
||||
|
||||
// Render the completed table.
|
||||
Table table;
|
||||
table.width (context.getWidth ());
|
||||
if (context.config.getBoolean ("obfuscate"))
|
||||
table.width (Context::getContext ().getWidth ());
|
||||
if (Context::getContext ().config.getBoolean ("obfuscate"))
|
||||
table.obfuscate ();
|
||||
table.add ("Wk");
|
||||
table.add ("Date");
|
||||
@@ -127,7 +125,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||
table.add ("Task");
|
||||
setHeaderUnderline (table);
|
||||
|
||||
auto dateformat = context.config.get ("dateformat");
|
||||
auto dateformat = Context::getContext ().config.get ("dateformat");
|
||||
|
||||
int previous_week = -1;
|
||||
std::string previous_date = "";
|
||||
@@ -189,7 +187,7 @@ int CmdTimesheet::execute (std::string& output)
|
||||
<< table.render ()
|
||||
<< '\n';
|
||||
|
||||
if (context.verbose ("affected"))
|
||||
if (Context::getContext ().verbose ("affected"))
|
||||
out << format ("{1} completed, {2} started.", num_completed, num_started)
|
||||
<< '\n';
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include <shared.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdUDAs::CmdUDAs ()
|
||||
{
|
||||
@@ -61,7 +59,7 @@ int CmdUDAs::execute (std::string& output)
|
||||
std::stringstream out;
|
||||
|
||||
std::vector <std::string> udas;
|
||||
for (auto& name : context.config)
|
||||
for (auto& name : Context::getContext ().config)
|
||||
{
|
||||
if (name.first.substr (0, 4) == "uda." &&
|
||||
name.first.find (".type") != std::string::npos)
|
||||
@@ -84,7 +82,7 @@ int CmdUDAs::execute (std::string& output)
|
||||
// Render a list of UDA name, type, label, allowed values,
|
||||
// possible default value, and finally the usage count.
|
||||
Table table;
|
||||
table.width (context.getWidth ());
|
||||
table.width (Context::getContext ().getWidth ());
|
||||
table.add ("Name");
|
||||
table.add ("Type");
|
||||
table.add ("Label");
|
||||
@@ -95,10 +93,10 @@ int CmdUDAs::execute (std::string& output)
|
||||
|
||||
for (auto& uda : udas)
|
||||
{
|
||||
std::string type = context.config.get ("uda." + uda + ".type");
|
||||
std::string label = context.config.get ("uda." + uda + ".label");
|
||||
std::string values = context.config.get ("uda." + uda + ".values");
|
||||
std::string defval = context.config.get ("uda." + uda + ".default");
|
||||
std::string type = Context::getContext ().config.get ("uda." + uda + ".type");
|
||||
std::string label = Context::getContext ().config.get ("uda." + uda + ".label");
|
||||
std::string values = Context::getContext ().config.get ("uda." + uda + ".values");
|
||||
std::string defval = Context::getContext ().config.get ("uda." + uda + ".default");
|
||||
if (label == "")
|
||||
label = uda;
|
||||
|
||||
@@ -137,7 +135,7 @@ int CmdUDAs::execute (std::string& output)
|
||||
{
|
||||
for (auto& att : i.data)
|
||||
if (att.first.substr (0, 11) != "annotation_" &&
|
||||
context.columns.find (att.first) == context.columns.end ())
|
||||
Context::getContext ().columns.find (att.first) == Context::getContext ().columns.end ())
|
||||
orphans[att.first]++;
|
||||
}
|
||||
|
||||
@@ -145,7 +143,7 @@ int CmdUDAs::execute (std::string& output)
|
||||
{
|
||||
// Display the orphans and their counts.
|
||||
Table orphanTable;
|
||||
orphanTable.width (context.getWidth ());
|
||||
orphanTable.width (Context::getContext ().getWidth ());
|
||||
orphanTable.add ("Orphan UDA");
|
||||
orphanTable.add ("Usage Count");
|
||||
setHeaderUnderline (orphanTable);
|
||||
@@ -190,7 +188,7 @@ CmdCompletionUDAs::CmdCompletionUDAs ()
|
||||
int CmdCompletionUDAs::execute (std::string& output)
|
||||
{
|
||||
std::vector <std::string> udas;
|
||||
for (auto& name : context.config)
|
||||
for (auto& name : Context::getContext ().config)
|
||||
{
|
||||
if (name.first.substr (0, 4) == "uda." &&
|
||||
name.first.find (".type") != std::string::npos)
|
||||
|
||||
@@ -28,8 +28,6 @@
|
||||
#include <CmdUndo.h>
|
||||
#include <Context.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdUndo::CmdUndo ()
|
||||
{
|
||||
@@ -49,7 +47,7 @@ CmdUndo::CmdUndo ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdUndo::execute (std::string&)
|
||||
{
|
||||
context.tdb2.revert ();
|
||||
Context::getContext ().tdb2.revert ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdUnique::CmdUnique ()
|
||||
{
|
||||
@@ -63,13 +61,13 @@ int CmdUnique::execute (std::string& output)
|
||||
std::string attribute {};
|
||||
|
||||
// Just the first arg.
|
||||
auto words = context.cli2.getWords ();
|
||||
auto words = Context::getContext ().cli2.getWords ();
|
||||
if (words.size () == 0)
|
||||
throw std::string ("An attribute must be specified. See 'task _columns'.");
|
||||
attribute = words[0];
|
||||
|
||||
std::string canonical;
|
||||
if (! context.cli2.canonicalize (canonical, "attribute", attribute))
|
||||
if (! Context::getContext ().cli2.canonicalize (canonical, "attribute", attribute))
|
||||
throw std::string ("You must specify an attribute or UDA.");
|
||||
|
||||
// Find the unique set of matching tasks.
|
||||
@@ -92,7 +90,7 @@ int CmdUnique::execute (std::string& output)
|
||||
for (auto& value : values)
|
||||
output += value + '\n';
|
||||
|
||||
context.headers.clear ();
|
||||
Context::getContext ().headers.clear ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
#include <main.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdUrgency::CmdUrgency ()
|
||||
{
|
||||
@@ -62,7 +60,7 @@ int CmdUrgency::execute (std::string& output)
|
||||
|
||||
if (filtered.size () == 0)
|
||||
{
|
||||
context.footnote ("No tasks specified.");
|
||||
Context::getContext ().footnote ("No tasks specified.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,6 @@
|
||||
#include <shared.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
CmdVersion::CmdVersion ()
|
||||
{
|
||||
@@ -60,7 +58,7 @@ int CmdVersion::execute (std::string& output)
|
||||
std::stringstream out;
|
||||
|
||||
// Create a table for the disclaimer.
|
||||
int width = context.getWidth ();
|
||||
int width = Context::getContext ().getWidth ();
|
||||
Table disclaimer;
|
||||
disclaimer.width (width);
|
||||
disclaimer.add ("");
|
||||
@@ -73,7 +71,7 @@ int CmdVersion::execute (std::string& output)
|
||||
link.set (link.addRow (), 0, "Documentation for Taskwarrior can be found using 'man task', 'man taskrc', 'man task-color', 'man task-sync' or at http://taskwarrior.org");
|
||||
|
||||
Color bold;
|
||||
if (context.color ())
|
||||
if (Context::getContext ().color ())
|
||||
bold = Color ("bold");
|
||||
|
||||
out << '\n'
|
||||
|
||||
@@ -90,8 +90,6 @@
|
||||
#include <ColProject.h>
|
||||
#include <ColDue.h>
|
||||
|
||||
extern Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Command::factory (std::map <std::string, Command*>& all)
|
||||
{
|
||||
@@ -174,7 +172,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||
|
||||
// Instantiate a command object for each custom report.
|
||||
std::vector <std::string> reports;
|
||||
for (auto &i : context.config)
|
||||
for (auto &i : Context::getContext ().config)
|
||||
{
|
||||
if (i.first.substr (0, 7) == "report.")
|
||||
{
|
||||
@@ -194,7 +192,7 @@ void Command::factory (std::map <std::string, Command*>& all)
|
||||
c = new CmdCustom (
|
||||
report,
|
||||
"task <filter> " + report,
|
||||
context.config.get ("report." + report + ".description"));
|
||||
Context::getContext ().config.get ("report." + report + ".description"));
|
||||
|
||||
all[c->keyword ()] = c;
|
||||
}
|
||||
@@ -334,8 +332,8 @@ bool Command::permission (
|
||||
|
||||
// What remains are write commands that have not yet selected 'all' or 'quit'.
|
||||
// Describe the task.
|
||||
bool confirmation = context.config.getBoolean ("confirmation");
|
||||
unsigned int bulk = context.config.getInteger ("bulk");
|
||||
bool confirmation = Context::getContext ().config.getBoolean ("confirmation");
|
||||
unsigned int bulk = Context::getContext ().config.getInteger ("bulk");
|
||||
|
||||
// Quantity 1 modifications have optional confirmation, and only (y/n).
|
||||
if (quantity == 1)
|
||||
@@ -353,7 +351,7 @@ bool Command::permission (
|
||||
if ((bulk == 0 || quantity < bulk) && (!_needs_confirm || !confirmation))
|
||||
return true;
|
||||
|
||||
if (context.verbose ("blank") && !_first_iteration)
|
||||
if (Context::getContext ().verbose ("blank") && !_first_iteration)
|
||||
std::cout << '\n';
|
||||
int answer = confirm4 (question);
|
||||
_first_iteration = false;
|
||||
|
||||
Reference in New Issue
Block a user