mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Classifier: Tries to identify arg types
This commit is contained in:
parent
c7696c3767
commit
152f20260b
2 changed files with 21 additions and 0 deletions
|
@ -39,3 +39,21 @@ std::vector <std::string> getKeywords (const std::vector <std::string>& args)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// enum class ArgType { binary, command, positional, keyword };
|
||||
ArgType classifyArg (const std::string& arg)
|
||||
{
|
||||
if (arg.find ("timew") == arg.length () - 5 ||
|
||||
arg.find ("ti") == arg.length () - 2)
|
||||
return ArgType::binary;
|
||||
|
||||
// TODO Commands are a problem.
|
||||
|
||||
if (arg[0] == ':')
|
||||
return ArgType::keyword;
|
||||
|
||||
// The positional args are really just the remainder after the others are
|
||||
// excluded.
|
||||
return ArgType::positional;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -43,6 +43,9 @@ int dispatchCommand (const std::vector <std::string>&, Database&, Rules&, Extens
|
|||
// classifier.cpp
|
||||
std::vector <std::string> getKeywords (const std::vector <std::string>&);
|
||||
|
||||
enum class ArgType { binary, command, positional, keyword };
|
||||
ArgType classifyArg (const std::string&);
|
||||
|
||||
// helper.cpp
|
||||
Color tagColor (const Rules&, const std::string&);
|
||||
std::string intervalSummarize (const Rules&, const Interval&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue