mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-30 02:17:21 +02:00
CLI
- The ::addArg method now trims incoming args.
This commit is contained in:
parent
d9712322a7
commit
f790ee65c4
1 changed files with 22 additions and 16 deletions
38
src/CLI.cpp
38
src/CLI.cpp
|
@ -588,22 +588,24 @@ const std::string CLI::dump (const std::string& title /* = "CLI Parser" */) cons
|
||||||
// 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)
|
||||||
{
|
{
|
||||||
|
std::string raw = trim (arg);
|
||||||
|
|
||||||
// Do not lex these constructs.
|
// Do not lex these constructs.
|
||||||
if (isTerminator (arg) || // --
|
if (isTerminator (raw) || // --
|
||||||
isRCOverride (arg) || // rc:<file>
|
isRCOverride (raw) || // rc:<file>
|
||||||
isConfigOverride (arg) || // rc.<attr>:<value>
|
isConfigOverride (raw) || // rc.<attr>:<value>
|
||||||
isCommand (arg) || // <cmd>
|
isCommand (raw) || // <cmd>
|
||||||
isTag (arg) || // [+-]<tag>
|
isTag (raw) || // [+-]<tag>
|
||||||
isUUIDList (arg) || // <uuid>,[uuid ...]
|
isUUIDList (raw) || // <uuid>,[uuid ...]
|
||||||
isUUID (arg) || // <uuid>
|
isUUID (raw) || // <uuid>
|
||||||
isIDSequence (arg) || // <id>[-<id>][,<id>[-<id>] ...]
|
isIDSequence (raw) || // <id>[-<id>][,<id>[-<id>] ...]
|
||||||
isID (arg) || // <id>
|
isID (raw) || // <id>
|
||||||
isPattern (arg) || // /<pattern</
|
isPattern (raw) || // /<pattern</
|
||||||
isSubstitution (arg) || // /<from>/<to>/[g]
|
isSubstitution (raw) || // /<from>/<to>/[g]
|
||||||
isAttribute (arg) || // <name>[.[~]<modfifier>]:<value>
|
isAttribute (raw) || // <name>[.[~]<modfifier>]:<value>
|
||||||
isOperator (arg)) // <operator>
|
isOperator (raw)) // <operator>
|
||||||
{
|
{
|
||||||
_original_args.push_back (arg);
|
_original_args.push_back (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lex, but only use lexemes if an operator is found in there.
|
// Lex, but only use lexemes if an operator is found in there.
|
||||||
|
@ -613,7 +615,7 @@ void CLI::addArg (const std::string& arg)
|
||||||
// otherwise no change.
|
// otherwise no change.
|
||||||
std::string lexeme;
|
std::string lexeme;
|
||||||
Lexer::Type type;
|
Lexer::Type type;
|
||||||
Lexer lex (arg);
|
Lexer lex (raw);
|
||||||
lex.ambiguity (false);
|
lex.ambiguity (false);
|
||||||
|
|
||||||
std::vector <std::pair <std::string, Lexer::Type> > lexemes;
|
std::vector <std::pair <std::string, Lexer::Type> > lexemes;
|
||||||
|
@ -631,10 +633,14 @@ void CLI::addArg (const std::string& arg)
|
||||||
foundOP)
|
foundOP)
|
||||||
{
|
{
|
||||||
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
for (l = lexemes.begin (); l != lexemes.end (); ++l)
|
||||||
|
{
|
||||||
_original_args.push_back (l->first);
|
_original_args.push_back (l->first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_original_args.push_back (arg);
|
{
|
||||||
|
_original_args.push_back (raw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue