feat(common): introduce common networking and CLI infrastructure
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#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";
|
||||
}
|
||||
Reference in New Issue
Block a user