add vectors
This commit is contained in:
parent
2fd9ab63fc
commit
d7271eda80
@ -51,6 +51,15 @@ namespace cxxopts
|
|||||||
is >> value;
|
is >> value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
parse_value(const std::string& text, std::vector<T>& value)
|
||||||
|
{
|
||||||
|
T v;
|
||||||
|
parse_value(text, v);
|
||||||
|
value.push_back(v);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct value_has_arg
|
struct value_has_arg
|
||||||
{
|
{
|
||||||
|
|||||||
10
src/main.cpp
10
src/main.cpp
@ -36,7 +36,7 @@ int main(int argc, char* argv[])
|
|||||||
options.add_options()
|
options.add_options()
|
||||||
("a,apple", "an apple")
|
("a,apple", "an apple")
|
||||||
("b,bob", "Bob")
|
("b,bob", "Bob")
|
||||||
("f,file", "File", cxxopts::value<std::string>())
|
("f,file", "File", cxxopts::value<std::vector<std::string>>())
|
||||||
("positional", "Positional arguments", cxxopts::value<std::string>())
|
("positional", "Positional arguments", cxxopts::value<std::string>())
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -56,8 +56,12 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if (options.count("f"))
|
if (options.count("f"))
|
||||||
{
|
{
|
||||||
std::cout << "File = " << options["f"].as<std::string>()
|
auto& ff = options["f"].as<std::vector<std::string>>();
|
||||||
<< std::endl;
|
std::cout << "Files" << std::endl;
|
||||||
|
for (const auto& f : ff)
|
||||||
|
{
|
||||||
|
std::cout << f << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.count("help"))
|
if (options.count("help"))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user