add option name to OptionDetails

This commit is contained in:
Jarryd Beck 2017-10-30 08:45:36 +11:00
parent b1f0cb806c
commit 7c32b9c5fc

View File

@ -844,10 +844,14 @@ namespace cxxopts
public: public:
OptionDetails OptionDetails
( (
const std::string& short_name,
const std::string& long_name,
const String& desc, const String& desc,
std::shared_ptr<const Value> val std::shared_ptr<const Value> val
) )
: m_desc(desc) : m_short(short_name)
, m_long(long_name)
, m_desc(desc)
, m_value(val) , m_value(val)
, m_count(0) , m_count(0)
{ {
@ -908,7 +912,21 @@ namespace cxxopts
return m_value->clone(); return m_value->clone();
} }
const std::string&
short_name() const
{
return m_short;
}
const std::string&
long_name() const
{
return m_long;
}
private: private:
std::string m_short;
std::string m_long;
String m_desc; String m_desc;
std::shared_ptr<const Value> m_value; std::shared_ptr<const Value> m_value;
int m_count; int m_count;
@ -1682,7 +1700,7 @@ Options::add_option
) )
{ {
auto stringDesc = toLocalString(std::move(desc)); auto stringDesc = toLocalString(std::move(desc));
auto option = std::make_shared<OptionDetails>(stringDesc, value); auto option = std::make_shared<OptionDetails>(s, l, stringDesc, value);
if (s.size() > 0) if (s.size() > 0)
{ {