35 lines
594 B
C++
35 lines
594 B
C++
#include "cli_base.hpp"
|
|
#include <boost/program_options/parsers.hpp>
|
|
#include <iostream>
|
|
|
|
CliBase::CliBase(const std::string &title)
|
|
: desc_(title)
|
|
, help_(false)
|
|
{
|
|
}
|
|
|
|
void CliBase::parse(int argc, char *argv[])
|
|
{
|
|
using namespace boost::program_options;
|
|
|
|
setupOptions(); // must be first
|
|
|
|
parsed_options parsed = parse_command_line(argc, argv, desc_);
|
|
store(parsed, vm_);
|
|
notify(vm_);
|
|
|
|
if (vm_.count("help")) {
|
|
help_ = true;
|
|
}
|
|
}
|
|
|
|
bool CliBase::isHelp() const
|
|
{
|
|
return help_;
|
|
}
|
|
|
|
void CliBase::printHelp() const
|
|
{
|
|
std::cout << desc_ << "\n";
|
|
}
|