mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 13:37:20 +02:00
Enhancement - debug support
- Added debug=on support. - Added color.debug= support.
This commit is contained in:
parent
173b3f6828
commit
02518e0223
7 changed files with 56 additions and 30 deletions
16
src/Att.cpp
16
src/Att.cpp
|
@ -63,21 +63,17 @@ static const char* modifiableNames[] =
|
||||||
"until",
|
"until",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Synonyms on the same line.
|
||||||
static const char* modifierNames[] =
|
static const char* modifierNames[] =
|
||||||
{
|
{
|
||||||
"before",
|
"before", "under", "below",
|
||||||
"after",
|
"after", "over", "above",
|
||||||
"under",
|
|
||||||
"over",
|
|
||||||
"below",
|
|
||||||
"above",
|
|
||||||
"none",
|
"none",
|
||||||
"any",
|
"any",
|
||||||
"is",
|
"is",
|
||||||
"isnt",
|
"isnt", "not",
|
||||||
"has",
|
"has", "contains",
|
||||||
"hasnt",
|
"hasnt",
|
||||||
"contains",
|
|
||||||
"startswith",
|
"startswith",
|
||||||
"endswith",
|
"endswith",
|
||||||
};
|
};
|
||||||
|
@ -486,7 +482,7 @@ bool Att::match (const Att& other) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// isnt = not equal.
|
// isnt = not equal.
|
||||||
else if (mMod == "isnt") // TODO i18n
|
else if (mMod == "isnt" || mMod == "not") // TODO i18n
|
||||||
{
|
{
|
||||||
if (mValue == other.mValue)
|
if (mValue == other.mValue)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -146,6 +146,11 @@ int Context::run ()
|
||||||
message (stringtable.get (100, "Unknown error."));
|
message (stringtable.get (100, "Unknown error."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Dump all debug messages.
|
||||||
|
if (config.get ("debug", true))
|
||||||
|
foreach (d, debugMessages)
|
||||||
|
std::cout << colorizeDebug (*d) << std::endl;
|
||||||
|
|
||||||
// Dump all headers.
|
// Dump all headers.
|
||||||
foreach (h, headers)
|
foreach (h, headers)
|
||||||
std::cout << colorizeHeader (*h) << std::endl;
|
std::cout << colorizeHeader (*h) << std::endl;
|
||||||
|
@ -367,7 +372,7 @@ void Context::parse (
|
||||||
// The '--' argument shuts off all parsing - everything is an argument.
|
// The '--' argument shuts off all parsing - everything is an argument.
|
||||||
if (*arg == "--")
|
if (*arg == "--")
|
||||||
{
|
{
|
||||||
header ("parse terminator '" + *arg + "'");
|
debug ("parse terminator '" + *arg + "'");
|
||||||
terminated = true;
|
terminated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +382,7 @@ void Context::parse (
|
||||||
! foundSomethingAfterSequence &&
|
! foundSomethingAfterSequence &&
|
||||||
parseSequence.valid (*arg))
|
parseSequence.valid (*arg))
|
||||||
{
|
{
|
||||||
header ("parse sequence '" + *arg + "'");
|
debug ("parse sequence '" + *arg + "'");
|
||||||
parseSequence.parse (*arg);
|
parseSequence.parse (*arg);
|
||||||
foundSequence = true;
|
foundSequence = true;
|
||||||
}
|
}
|
||||||
|
@ -387,7 +392,7 @@ void Context::parse (
|
||||||
(*arg)[0] == '+' &&
|
(*arg)[0] == '+' &&
|
||||||
validTag (*arg))
|
validTag (*arg))
|
||||||
{
|
{
|
||||||
header ("parse tag addition '" + *arg + "'");
|
debug ("parse tag addition '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
foundSomethingAfterSequence = true;
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
|
@ -404,7 +409,7 @@ void Context::parse (
|
||||||
(*arg)[0] == '-' &&
|
(*arg)[0] == '-' &&
|
||||||
validTag (*arg))
|
validTag (*arg))
|
||||||
{
|
{
|
||||||
header ("parse tag removal '" + *arg + "'");
|
debug ("parse tag removal '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
foundSomethingAfterSequence = true;
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
|
@ -418,7 +423,7 @@ void Context::parse (
|
||||||
// Atributes - name[.mod]:[value]
|
// Atributes - name[.mod]:[value]
|
||||||
else if (attribute.valid (*arg))
|
else if (attribute.valid (*arg))
|
||||||
{
|
{
|
||||||
header ("parse attribute '" + *arg + "'");
|
debug ("parse attribute '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
foundSomethingAfterSequence = true;
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
|
@ -456,7 +461,7 @@ void Context::parse (
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
foundSomethingAfterSequence = true;
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
header ("parse subst '" + *arg + "'");
|
debug ("parse subst '" + *arg + "'");
|
||||||
parseSubst.parse (*arg);
|
parseSubst.parse (*arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +469,7 @@ void Context::parse (
|
||||||
else if (parseCmd.command == "" &&
|
else if (parseCmd.command == "" &&
|
||||||
parseCmd.valid (*arg))
|
parseCmd.valid (*arg))
|
||||||
{
|
{
|
||||||
header ("parse cmd '" + *arg + "'");
|
debug ("parse cmd '" + *arg + "'");
|
||||||
parseCmd.parse (*arg);
|
parseCmd.parse (*arg);
|
||||||
|
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
|
@ -486,7 +491,7 @@ void Context::parse (
|
||||||
// terminated, therefore everything subsequently is a description.
|
// terminated, therefore everything subsequently is a description.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
header ("parse post-termination description '" + *arg + "'");
|
debug ("parse post-termination description '" + *arg + "'");
|
||||||
if (foundSequence)
|
if (foundSequence)
|
||||||
foundSomethingAfterSequence = true;
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
|
@ -498,7 +503,7 @@ void Context::parse (
|
||||||
|
|
||||||
if (descCandidate != "" && noVerticalSpace (descCandidate))
|
if (descCandidate != "" && noVerticalSpace (descCandidate))
|
||||||
{
|
{
|
||||||
header ("parse description '" + descCandidate + "'");
|
debug ("parse description '" + descCandidate + "'");
|
||||||
parseTask.set ("description", descCandidate);
|
parseTask.set ("description", descCandidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,6 +608,12 @@ void Context::footnote (const std::string& input)
|
||||||
footnotes.push_back (input);
|
footnotes.push_back (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Context::debug (const std::string& input)
|
||||||
|
{
|
||||||
|
debugMessages.push_back (input);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Context::clearMessages ()
|
void Context::clearMessages ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
void header (const std::string&); // Header sink
|
void header (const std::string&); // Header sink
|
||||||
void message (const std::string&); // Message sink
|
void message (const std::string&); // Message sink
|
||||||
void footnote (const std::string&); // Footnote sink
|
void footnote (const std::string&); // Footnote sink
|
||||||
|
void debug (const std::string&); // Debug message sink
|
||||||
void clearMessages ();
|
void clearMessages ();
|
||||||
|
|
||||||
void parse ();
|
void parse ();
|
||||||
|
@ -83,6 +84,7 @@ private:
|
||||||
std::vector <std::string> headers;
|
std::vector <std::string> headers;
|
||||||
std::vector <std::string> messages;
|
std::vector <std::string> messages;
|
||||||
std::vector <std::string> footnotes;
|
std::vector <std::string> footnotes;
|
||||||
|
std::vector <std::string> debugMessages;
|
||||||
bool inShadow;
|
bool inShadow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -389,8 +389,6 @@ int TDB::gc ()
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
context.header ("gc");
|
|
||||||
|
|
||||||
// Set up a second TDB.
|
// Set up a second TDB.
|
||||||
Filter filter;
|
Filter filter;
|
||||||
TDB tdb;
|
TDB tdb;
|
||||||
|
@ -443,6 +441,9 @@ int TDB::gc ()
|
||||||
// Close files.
|
// Close files.
|
||||||
tdb.unlock ();
|
tdb.unlock ();
|
||||||
|
|
||||||
|
std::stringstream s;
|
||||||
|
s << "gc " << count << " tasks";
|
||||||
|
context.debug (s.str ());
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -380,15 +380,15 @@ std::string handleVersion ()
|
||||||
std::string recognized =
|
std::string recognized =
|
||||||
" blanklines color color.active color.due color.overdue color.pri.H "
|
" blanklines color color.active color.due color.overdue color.pri.H "
|
||||||
"color.pri.L color.pri.M color.pri.none color.recurring color.tagged "
|
"color.pri.L color.pri.M color.pri.none color.recurring color.tagged "
|
||||||
"color.footnote color.message confirmation curses data.location dateformat "
|
"color.footnote color.header color.message color.debug confirmation curses "
|
||||||
"default.command default.priority defaultwidth displayweeknumber due "
|
"data.location dateformat default.command default.priority defaultwidth "
|
||||||
"echo.command locale locking monthsperline nag next project shadow.command "
|
"displayweeknumber due echo.command locale locking monthsperline nag next "
|
||||||
"shadow.file shadow.notify weekstart editor import.synonym.id "
|
"project shadow.command shadow.file shadow.notify weekstart editor "
|
||||||
"import.synonym.uuid import.synonym.status import.synonym.tags "
|
"import.synonym.id import.synonym.uuid import.synonym.status "
|
||||||
"import.synonym.entry import.synonym.start import.synonym.due "
|
"import.synonym.tags import.synonym.entry import.synonym.start "
|
||||||
"import.synonym.recur import.synonym.end import.synonym.project "
|
"import.synonym.due import.synonym.recur import.synonym.end "
|
||||||
"import.synonym.priority import.synonym.fg import.synonym.bg "
|
"import.synonym.project import.synonym.priority import.synonym.fg "
|
||||||
"import.synonym.description ";
|
"import.synonym.bg import.synonym.description ";
|
||||||
|
|
||||||
// This configuration variable is supported, but not documented. It exists
|
// This configuration variable is supported, but not documented. It exists
|
||||||
// so that unit tests can force color to be on even when the output from task
|
// so that unit tests can force color to be on even when the output from task
|
||||||
|
|
|
@ -105,6 +105,7 @@ void autoColorize (Task&, Text::color&, Text::color&);
|
||||||
std::string colorizeHeader (const std::string&);
|
std::string colorizeHeader (const std::string&);
|
||||||
std::string colorizeMessage (const std::string&);
|
std::string colorizeMessage (const std::string&);
|
||||||
std::string colorizeFootnote (const std::string&);
|
std::string colorizeFootnote (const std::string&);
|
||||||
|
std::string colorizeDebug (const std::string&);
|
||||||
|
|
||||||
// import.cpp
|
// import.cpp
|
||||||
std::string handleImport ();
|
std::string handleImport ();
|
||||||
|
|
|
@ -281,4 +281,19 @@ std::string colorizeFootnote (const std::string& input)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
std::string colorizeDebug (const std::string& input)
|
||||||
|
{
|
||||||
|
if (gsFg["debug.footnote"] != Text::nocolor ||
|
||||||
|
gsBg["debug.footnote"] != Text::nocolor)
|
||||||
|
{
|
||||||
|
return Text::colorize (
|
||||||
|
gsFg["debug.footnote"],
|
||||||
|
gsBg["debug.footnote"],
|
||||||
|
input);
|
||||||
|
}
|
||||||
|
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue