Commit 7e3fccd5 authored by aligungr's avatar aligungr

Options parser improvement

parent 51a29493
...@@ -222,9 +222,14 @@ opt::OptionsResult::OptionsResult(int argc, char **argv, const opt::OptionsDescr ...@@ -222,9 +222,14 @@ opt::OptionsResult::OptionsResult(int argc, char **argv, const opt::OptionsDescr
bool opt::OptionsResult::hasFlag(const opt::OptionItem &item) const bool opt::OptionsResult::hasFlag(const opt::OptionItem &item) const
{ {
if (item.shortName.has_value() && m_options.count(std::string(1, *item.shortName)) > 0) return hasFlag(item.shortName, item.longName);
}
bool opt::OptionsResult::hasFlag(const std::optional<char> &shortName, const std::optional<std::string> &longName) const
{
if (shortName.has_value() && m_options.count(std::string(1, *shortName)) > 0)
return true; return true;
if (item.longName.has_value() && m_options.count(*item.longName) > 0) if (longName.has_value() && m_options.count(*longName) > 0)
return true; return true;
return false; return false;
} }
......
...@@ -107,6 +107,7 @@ class OptionsResult ...@@ -107,6 +107,7 @@ class OptionsResult
public: public:
bool hasFlag(const OptionItem &item) const; bool hasFlag(const OptionItem &item) const;
bool hasFlag(const std::optional<char> &shortName, const std::optional<std::string>& longName) const;
int positionalCount() const; int positionalCount() const;
int count() const; int count() const;
std::string getPositional(int index) const; std::string getPositional(int index) const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment