2019-08-08 17:54:29 +00:00
|
|
|
#include "options.hpp"
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-08-18 20:07:51 +00:00
|
|
|
template<typename Iterator>
|
|
|
|
void print_list(std::ostream& out, Iterator start, Iterator end)
|
2019-08-08 17:54:29 +00:00
|
|
|
{
|
2020-08-18 20:07:51 +00:00
|
|
|
if (start == end)
|
|
|
|
{
|
|
|
|
out << "<empty>";
|
|
|
|
return;
|
|
|
|
}
|
2019-08-08 17:54:29 +00:00
|
|
|
|
2020-08-18 20:07:51 +00:00
|
|
|
for (; start != end; ++start)
|
2019-08-08 17:54:29 +00:00
|
|
|
{
|
2020-08-18 20:07:51 +00:00
|
|
|
out << '"' << *start << '"';
|
2019-08-08 17:54:29 +00:00
|
|
|
|
2020-08-18 20:07:51 +00:00
|
|
|
if (std::next(start) != end)
|
2019-08-08 17:54:29 +00:00
|
|
|
{
|
2020-08-18 20:07:51 +00:00
|
|
|
out << ", ";
|
2019-08-08 17:54:29 +00:00
|
|
|
}
|
2020-08-18 20:07:51 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-08 17:54:29 +00:00
|
|
|
|
2020-08-18 20:07:51 +00:00
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
auto [opts, operands] = options::parse(argv + 1, argv + argc);
|
|
|
|
|
|
|
|
std::cerr << "Operands: ";
|
|
|
|
print_list(std::cerr, std::cbegin(operands), std::cend(operands));
|
|
|
|
std::cerr << '\n';
|
2019-08-08 17:54:29 +00:00
|
|
|
|
2020-08-18 20:07:51 +00:00
|
|
|
for (const auto& [name, args] : opts)
|
|
|
|
{
|
|
|
|
std::cerr << "“" << name << "”: ";
|
|
|
|
print_list(std::cerr, std::cbegin(args), std::cend(args));
|
2019-08-08 17:54:29 +00:00
|
|
|
std::cerr << '\n';
|
|
|
|
}
|
|
|
|
}
|