options/main.cpp

39 lines
810 B
C++

#include "options.hpp"
#include <iostream>
template<typename Iterator>
void print_list(std::ostream& out, Iterator start, Iterator end)
{
if (start == end)
{
out << "<empty>";
return;
}
for (; start != end; ++start)
{
out << '"' << *start << '"';
if (std::next(start) != end)
{
out << ", ";
}
}
}
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';
for (const auto& [name, args] : opts)
{
std::cerr << "" << name << "”: ";
print_list(std::cerr, std::cbegin(args), std::cend(args));
std::cerr << '\n';
}
}