mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 11:27:19 +02:00
CLI
- Implemented ::isSubstitution and used it.
This commit is contained in:
parent
7b67e77752
commit
52a6cfd4a0
2 changed files with 19 additions and 10 deletions
26
src/CLI.cpp
26
src/CLI.cpp
|
@ -480,22 +480,16 @@ const std::string CLI::dump () const
|
||||||
// Either the arg is appended to _original_args intact, or the lexemes are.
|
// Either the arg is appended to _original_args intact, or the lexemes are.
|
||||||
void CLI::addArg (const std::string& arg)
|
void CLI::addArg (const std::string& arg)
|
||||||
{
|
{
|
||||||
// Do not lex RC overrides, UUIDs, patterns.
|
// Do not lex RC overrides, UUIDs, patterns, substitutions.
|
||||||
if (isRCOverride (arg) ||
|
if (isRCOverride (arg) ||
|
||||||
isConfigOverride (arg) ||
|
isConfigOverride (arg) ||
|
||||||
isUUID (arg) ||
|
isUUID (arg) ||
|
||||||
isPattern (arg))
|
isPattern (arg) ||
|
||||||
|
isSubstitution (arg))
|
||||||
{
|
{
|
||||||
_original_args.push_back (arg);
|
_original_args.push_back (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not lex substitutions.
|
|
||||||
else if (arg.length () > 2 &&
|
|
||||||
arg[0] == '/' &&
|
|
||||||
arg[arg.length () - 2] == '/' &&
|
|
||||||
arg[arg.length () - 1] == 'g')
|
|
||||||
_original_args.push_back (arg);
|
|
||||||
|
|
||||||
// Do not lex, unless lexing reveals OPs.
|
// Do not lex, unless lexing reveals OPs.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1733,3 +1727,17 @@ bool CLI::isPattern (const std::string& raw) const
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// The non-g case is caught by ::isPattern, but not categorized, so it doesn't
|
||||||
|
// matter.
|
||||||
|
bool CLI::isSubstitution (const std::string& raw) const
|
||||||
|
{
|
||||||
|
if (raw.length () > 3 && // /x// = length 4
|
||||||
|
raw[0] == '/' &&
|
||||||
|
raw[raw.length () - 2] == '/' &&
|
||||||
|
raw[raw.length () - 1] == 'g')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -102,6 +102,7 @@ private:
|
||||||
bool isConfigOverride (const std::string&) const;
|
bool isConfigOverride (const std::string&) const;
|
||||||
bool isUUID (const std::string&) const;
|
bool isUUID (const std::string&) const;
|
||||||
bool isPattern (const std::string&) const;
|
bool isPattern (const std::string&) const;
|
||||||
|
bool isSubstitution (const std::string&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::multimap <std::string, std::string> _entities;
|
std::multimap <std::string, std::string> _entities;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue