From 152f20260baeca91c23fea75a86ba49641bb0b55 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 2 Apr 2016 12:18:01 -0400 Subject: [PATCH] Classifier: Tries to identify arg types --- src/classifier.cpp | 18 ++++++++++++++++++ src/timew.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/src/classifier.cpp b/src/classifier.cpp index f46b5372..3fb209c5 100644 --- a/src/classifier.cpp +++ b/src/classifier.cpp @@ -39,3 +39,21 @@ std::vector getKeywords (const std::vector & 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; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/timew.h b/src/timew.h index a1115b00..db06f84e 100644 --- a/src/timew.h +++ b/src/timew.h @@ -43,6 +43,9 @@ int dispatchCommand (const std::vector &, Database&, Rules&, Extens // classifier.cpp std::vector getKeywords (const std::vector &); +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&);