mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Verbosity: Fix "project" info not showing
- Make "project" verbosity imply "footnote", since verbose project info is shown using footnotes. Fixes failing test in verbose.t. - Convert "verbosity" variable to std::set for increased readability.
This commit is contained in:
parent
124f1fe4c8
commit
ae692e07a6
6 changed files with 63 additions and 21 deletions
|
@ -18,6 +18,8 @@ Babej).
|
|||
- Show the active context in "context list", if any is active.
|
||||
- Fix "task edit" dropping annotation text after newlines.
|
||||
- Removed obsolete script 'context'.
|
||||
- Fix "project" verbosity info not showing without "footnote" being manually
|
||||
enabled.
|
||||
|
||||
------ current release ---------------------------
|
||||
|
||||
|
|
|
@ -275,6 +275,8 @@ control specific occasions when output is generated. This list may contain:
|
|||
sync Feedback about sync
|
||||
filter Shows the filter used in the command
|
||||
|
||||
"affected", "new-id", "new-uuid" and "project" imply "footnote".
|
||||
|
||||
Note that the "on" setting is equivalent to all the tokens being specified,
|
||||
and the "nothing" setting is equivalent to none of the tokens being specified.
|
||||
|
||||
|
|
|
@ -508,7 +508,7 @@ bool Context::color ()
|
|||
// take the place of '0'.
|
||||
bool Context::verbose (const std::string& token)
|
||||
{
|
||||
if (! verbosity.size ())
|
||||
if (verbosity.empty ())
|
||||
{
|
||||
verbosity_legacy = config.getBoolean ("verbose");
|
||||
split (verbosity, config.get ("verbose"), ',');
|
||||
|
@ -517,24 +517,40 @@ bool Context::verbose (const std::string& token)
|
|||
// This odd test is to see if a Boolean-false value is a real one, which
|
||||
// means it is not 1/true/T/yes/on, but also should not be one of the
|
||||
// valid tokens either.
|
||||
if (!verbosity_legacy &&
|
||||
verbosity.size () &&
|
||||
verbosity[0] != "nothing" &&
|
||||
verbosity[0] != "blank" && // This list must be complete.
|
||||
verbosity[0] != "header" && //
|
||||
verbosity[0] != "footnote" && //
|
||||
verbosity[0] != "label" && //
|
||||
verbosity[0] != "new-id" && //
|
||||
verbosity[0] != "new-uuid" && //
|
||||
verbosity[0] != "affected" && //
|
||||
verbosity[0] != "edit" && //
|
||||
verbosity[0] != "special" && //
|
||||
verbosity[0] != "project" && //
|
||||
verbosity[0] != "sync" && //
|
||||
verbosity[0] != "filter") //
|
||||
if (!verbosity_legacy && ! verbosity.empty ())
|
||||
{
|
||||
// This list emulates rc.verbose=off in version 1.9.4.
|
||||
verbosity = {"blank", "label", "new-id", "edit"};
|
||||
std::string v = *(verbosity.begin ());
|
||||
if (v != "nothing" &&
|
||||
v != "blank" && // This list must be complete.
|
||||
v != "header" && //
|
||||
v != "footnote" && //
|
||||
v != "label" && //
|
||||
v != "new-id" && //
|
||||
v != "new-uuid" && //
|
||||
v != "affected" && //
|
||||
v != "edit" && //
|
||||
v != "special" && //
|
||||
v != "project" && //
|
||||
v != "sync" && //
|
||||
v != "filter") //
|
||||
{
|
||||
// This list emulates rc.verbose=off in version 1.9.4.
|
||||
verbosity = {"blank", "label", "new-id", "edit"};
|
||||
}
|
||||
}
|
||||
|
||||
// Some flags imply "footnote" verbosity being active. Make it so.
|
||||
if (! verbosity.count ("footnote"))
|
||||
{
|
||||
// TODO: Some of these may not use footnotes yet. They should.
|
||||
for (auto flag : {"affected", "new-id", "new-uuid", "project"})
|
||||
{
|
||||
if (verbosity.count (flag))
|
||||
{
|
||||
verbosity.insert ("footnote");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -544,11 +560,11 @@ bool Context::verbose (const std::string& token)
|
|||
|
||||
// rc.verbose=nothing overrides all.
|
||||
if (verbosity.size () == 1 &&
|
||||
verbosity[0] == "nothing")
|
||||
*(verbosity.begin ()) == "nothing")
|
||||
return false;
|
||||
|
||||
// Specific token match.
|
||||
if (std::find (verbosity.begin (), verbosity.end (), token) != verbosity.end ())
|
||||
if (verbosity.count (token))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <FS.h>
|
||||
#include <CLI.h>
|
||||
#include <Timer.h>
|
||||
#include <set>
|
||||
|
||||
class Context
|
||||
{
|
||||
|
@ -95,7 +96,7 @@ public:
|
|||
bool run_gc;
|
||||
|
||||
bool verbosity_legacy;
|
||||
std::vector <std::string> verbosity;
|
||||
std::set <std::string> verbosity;
|
||||
std::vector <std::string> headers;
|
||||
std::vector <std::string> footnotes;
|
||||
std::vector <std::string> errors;
|
||||
|
|
19
src/text.cpp
19
src/text.cpp
|
@ -60,6 +60,25 @@ void wrapText (
|
|||
lines.push_back (line);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void split (
|
||||
std::set<std::string>& results,
|
||||
const std::string& input,
|
||||
const char delimiter)
|
||||
{
|
||||
results.clear ();
|
||||
std::string::size_type start = 0;
|
||||
std::string::size_type i;
|
||||
while ((i = input.find (delimiter, start)) != std::string::npos)
|
||||
{
|
||||
results.insert (input.substr (start, i - start));
|
||||
start = i + 1;
|
||||
}
|
||||
|
||||
if (input.length ())
|
||||
results.insert (input.substr (start));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void split (
|
||||
std::vector<std::string>& results,
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#ifndef INCLUDED_TEXT
|
||||
#define INCLUDED_TEXT
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -39,6 +40,7 @@ std::string unquoteText (const std::string&);
|
|||
int longestWord (const std::string&);
|
||||
int longestLine (const std::string&);
|
||||
bool extractLine (std::string&, const std::string&, int, bool, unsigned int&);
|
||||
void split (std::set<std::string>&, const std::string&, const char);
|
||||
void split (std::vector<std::string>&, const std::string&, const char);
|
||||
void split (std::vector<std::string>&, const std::string&, const std::string&);
|
||||
void join (std::string&, const std::string&, const std::vector<std::string>&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue