Commit 7c32b9c5fc66c4ede91670910090bc729a28ee4e

Authored by Jarryd Beck
1 parent b1f0cb80

add option name to OptionDetails

Showing 1 changed file with 20 additions and 2 deletions
include/cxxopts.hpp
... ... @@ -844,10 +844,14 @@ namespace cxxopts
844 844 public:
845 845 OptionDetails
846 846 (
  847 + const std::string& short_name,
  848 + const std::string& long_name,
847 849 const String& desc,
848 850 std::shared_ptr<const Value> val
849 851 )
850   - : m_desc(desc)
  852 + : m_short(short_name)
  853 + , m_long(long_name)
  854 + , m_desc(desc)
851 855 , m_value(val)
852 856 , m_count(0)
853 857 {
... ... @@ -908,7 +912,21 @@ namespace cxxopts
908 912 return m_value->clone();
909 913 }
910 914  
  915 + const std::string&
  916 + short_name() const
  917 + {
  918 + return m_short;
  919 + }
  920 +
  921 + const std::string&
  922 + long_name() const
  923 + {
  924 + return m_long;
  925 + }
  926 +
911 927 private:
  928 + std::string m_short;
  929 + std::string m_long;
912 930 String m_desc;
913 931 std::shared_ptr<const Value> m_value;
914 932 int m_count;
... ... @@ -1682,7 +1700,7 @@ Options::add_option
1682 1700 )
1683 1701 {
1684 1702 auto stringDesc = toLocalString(std::move(desc));
1685   - auto option = std::make_shared<OptionDetails>(stringDesc, value);
  1703 + auto option = std::make_shared<OptionDetails>(s, l, stringDesc, value);
1686 1704  
1687 1705 if (s.size() > 0)
1688 1706 {
... ...