options/main.cpp

43 lines
893 B
C++

#include "options.hpp"
#include <iostream>
int main(int argc, char** argv)
{
auto opts = options::parse(argv + 1, argv + argc);
for (const auto& [name, args] : opts)
{
if (name == options::operands)
{
std::cerr << "Operands: ";
}
else
{
std::cerr << '"' << name << "\": ";
}
if (args.empty())
{
std::cerr << "(no arguments)";
}
else
{
for (
auto value_it = std::cbegin(args);
value_it != std::cend(args);
++value_it
)
{
std::cerr << '"' << *value_it << '"';
if (std::next(value_it) != std::cend(args))
{
std::cerr << ", ";
}
}
}
std::cerr << '\n';
}
}