mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 17:07:19 +02:00
Enhancements - Cmd object
- New Cmd object to handle localized commands, customReports and general command parsing. - Localized new Subst methods. - Relocate guess method from parse.cpp to text.cpp. - Converted Att object to use new valid/parse scheme. - Unit tests for Cmd object. - Fixed att.t.cpp unit tests.
This commit is contained in:
parent
ffa0c6e758
commit
24f31eeb00
17 changed files with 416 additions and 52 deletions
32
src/text.cpp
32
src/text.cpp
|
@ -305,3 +305,35 @@ const char* optionalBlankLine ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void guess (
|
||||
const std::string& type,
|
||||
std::vector<std::string>& options,
|
||||
std::string& candidate)
|
||||
{
|
||||
std::vector <std::string> matches;
|
||||
autoComplete (candidate, options, matches);
|
||||
if (1 == matches.size ())
|
||||
candidate = matches[0];
|
||||
|
||||
else if (0 == matches.size ())
|
||||
candidate = "";
|
||||
|
||||
else
|
||||
{
|
||||
std::string error = "Ambiguous "; // TODO i18n
|
||||
error += type;
|
||||
error += " '";
|
||||
error += candidate;
|
||||
error += "' - could be either of "; // TODO i18n
|
||||
for (size_t i = 0; i < matches.size (); ++i)
|
||||
{
|
||||
if (i)
|
||||
error += ", ";
|
||||
error += matches[i];
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue