mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CLI: Removed ::findCommand, which is replaced by ::canonicalizeNames
This commit is contained in:
parent
68ba48e85f
commit
2360509b98
2 changed files with 0 additions and 34 deletions
33
src/CLI.cpp
33
src/CLI.cpp
|
@ -223,7 +223,6 @@ void CLI::analyze ()
|
|||
_args.clear ();
|
||||
handleArg0 ();
|
||||
lexArguments ();
|
||||
findCommand ();
|
||||
canonicalizeNames ();
|
||||
}
|
||||
|
||||
|
@ -328,38 +327,6 @@ void CLI::canonicalizeNames ()
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Scan all arguments and if any are an exact match for a command name, then
|
||||
// tag as CMD. If an argument is an exact match for an attribute, despite being
|
||||
// an inexact match for a command, then it is not a command.
|
||||
bool CLI::findCommand ()
|
||||
{
|
||||
for (auto& a : _args)
|
||||
{
|
||||
auto raw = a.attribute ("raw");
|
||||
std::string canonical;
|
||||
|
||||
// If the arg canonicalized to a 'cmd', but is also not an exact match
|
||||
// for an 'attribute', proceed. Example:
|
||||
// task project=foo list
|
||||
// ^cmd ^cmd
|
||||
// ^attribute
|
||||
if (exactMatch ("command", raw))
|
||||
canonical = raw;
|
||||
else if (! canonicalize (canonical, "command", raw))
|
||||
continue;
|
||||
|
||||
a.attribute ("canonical", canonical);
|
||||
a.tag ("CMD");
|
||||
|
||||
// Stop and indicate command found.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Indicate command not found.
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Search for exact 'value' in _entities category.
|
||||
bool CLI::exactMatch (
|
||||
|
|
|
@ -66,7 +66,6 @@ private:
|
|||
void handleArg0 ();
|
||||
void lexArguments ();
|
||||
void canonicalizeNames ();
|
||||
bool findCommand ();
|
||||
bool exactMatch (const std::string&, const std::string&) const;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue