mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI
- Implemented ::isIDSequence.
This commit is contained in:
parent
28a2d667f1
commit
1136b8fcdc
2 changed files with 37 additions and 0 deletions
36
src/CLI.cpp
36
src/CLI.cpp
|
@ -485,6 +485,7 @@ void CLI::addArg (const std::string& arg)
|
|||
isConfigOverride (arg) ||
|
||||
isUUIDList (arg) ||
|
||||
isUUID (arg) ||
|
||||
isIDSequence (arg) ||
|
||||
isID (arg) ||
|
||||
isPattern (arg) ||
|
||||
isSubstitution (arg))
|
||||
|
@ -1741,6 +1742,41 @@ bool CLI::isUUID (const std::string& raw) const
|
|||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::isIDSequence (const std::string& raw) const
|
||||
{
|
||||
if (raw.find_first_not_of ("0123456789,-") == std::string::npos)
|
||||
{
|
||||
// Split the ID list into elements.
|
||||
std::vector <std::string> elements;
|
||||
split (elements, raw, ',');
|
||||
|
||||
std::vector <std::string>::iterator e;
|
||||
for (e = elements.begin (); e != elements.end (); ++e)
|
||||
{
|
||||
// Split the ID range into min/max.
|
||||
std::vector <std::string> terms;
|
||||
split (terms, *e, '-');
|
||||
|
||||
if (terms.size () == 1 &&
|
||||
! isID (terms[0]))
|
||||
return false;
|
||||
|
||||
else if (terms.size () == 2 &&
|
||||
(! isID (terms[0]) ||
|
||||
! isID (terms[1])))
|
||||
return false;
|
||||
|
||||
else if (terms.size () > 2)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::isID (const std::string& raw) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue