Commit 8b224fa7a9a31df86278f4cad44144947d04b39f

Authored by Henry Fredrick Schreiner
1 parent 9dea0cf2

Allowing comma sep. options everywhere

Showing 1 changed file with 48 additions and 2 deletions
include/CLI.hpp
@@ -844,6 +844,18 @@ public: @@ -844,6 +844,18 @@ public:
844 } 844 }
845 845
846 846
  847 + template<typename T, typename... Args>
  848 + Option* add_set(
  849 + std::string name, ///< The name, short,long
  850 + T &member, ///< The selected member of the set
  851 + std::set<T> options, ///< The set of posibilities
  852 + std::string discription, ///< Discription string
  853 + detail::Combiner opts, ///< The options (REQUIRED, DEFAULT, POSITIONAL, ARGS())
  854 + detail::Combiner opts2,
  855 + Args... args
  856 + ) {
  857 + return add_set(name, member, options, discription, opts|opts2, args...);
  858 + }
847 859
848 860
849 //------------ MAKE STYLE ---------// 861 //------------ MAKE STYLE ---------//
@@ -877,6 +889,17 @@ public: @@ -877,6 +889,17 @@ public:
877 retval->typeval = detail::type_name<T>(); 889 retval->typeval = detail::type_name<T>();
878 return out; 890 return out;
879 } 891 }
  892 +
  893 + template<typename T = std::string, typename... Args>
  894 + Value<T> make_option(
  895 + std::string name, ///< The name, short,long
  896 + std::string discription,
  897 + detail::Combiner opts,
  898 + detail::Combiner opts2,
  899 + Args... args
  900 + ) {
  901 + return make_option(name, discription, opts|opts2, args...);
  902 + }
880 903
881 /// Prototype for new output style with default 904 /// Prototype for new output style with default
882 template<typename T, 905 template<typename T,
@@ -912,7 +935,7 @@ public: @@ -912,7 +935,7 @@ public:
912 retval->defaultval = ot.str(); 935 retval->defaultval = ot.str();
913 return out; 936 return out;
914 } 937 }
915 - 938 +
916 /// Prototype for new output style, vector 939 /// Prototype for new output style, vector
917 template<typename T, 940 template<typename T,
918 enable_if_t<is_vector<T>::value, detail::enabler> = detail::dummy> 941 enable_if_t<is_vector<T>::value, detail::enabler> = detail::dummy>
@@ -943,6 +966,18 @@ public: @@ -943,6 +966,18 @@ public:
943 return out; 966 return out;
944 } 967 }
945 968
  969 +
  970 + template<typename T, typename... Args>
  971 + Value<T> make_option(
  972 + std::string name, ///< The name, short,long
  973 + const T& default_value,
  974 + std::string discription,
  975 + detail::Combiner opts,
  976 + detail::Combiner opts2,
  977 + Args... args
  978 + ) {
  979 + return make_option(name, default_value, discription, opts|opts2, args...);
  980 + }
946 981
947 /// Prototype for new output style: flag 982 /// Prototype for new output style: flag
948 Value<int> make_flag( 983 Value<int> make_flag(
@@ -998,7 +1033,18 @@ public: @@ -998,7 +1033,18 @@ public:
998 return out; 1033 return out;
999 } 1034 }
1000 1035
1001 - 1036 +
  1037 + template<typename T, typename... Args>
  1038 + Value<T> make_set(
  1039 + std::string name,
  1040 + std::set<T> options,
  1041 + std::string discription,
  1042 + detail::Combiner opts,
  1043 + detail::Combiner opts2,
  1044 + Args... args
  1045 + ) {
  1046 + return make_set(name, options, discription, opts|opts2, args...);
  1047 + }
1002 1048
1003 /// Parses the command line - throws errors 1049 /// Parses the command line - throws errors
1004 void parse(int argc, char **argv) { 1050 void parse(int argc, char **argv) {