Classifier: Tries to identify arg types

This commit is contained in:
Paul Beckingham 2016-04-02 12:18:01 -04:00
parent c7696c3767
commit 152f20260b
2 changed files with 21 additions and 0 deletions

View file

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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&);