7#include <boost/program_options.hpp>
12namespace po = boost::program_options;
16 po::options_description required(
"Required options");
18 required.add_options()
19 (
"filename,f", po::value(&
sFullFilename)->value_name(
"<outputDir>")->required(),
20 "Full path to TSA file")
24 po::options_description optional{
"Other options"};
26 optional.add_options()
28 "number of timeslices")
30 "SysId to select (component level), in hex! 0x00 to 0xFF!")
36 "number of microslices to dump per component")
37 (
"help,h",
"Print help message")
42 po::options_description cmdline_options;
43 cmdline_options.add(required).add(optional);
46 po::command_line_parser parser{argc, argv};
47 parser.options(cmdline_options);
49 auto result = parser.run();
50 po::store(result, vm);
52 catch (
const std::exception& e) {
53 std::cerr <<
"Error: " << e.what() << std::endl;
54 std::cerr <<
"Use '-h' to display all valid options." << std::endl;
55 std::exit(EXIT_FAILURE);
58 if (vm.count(
"help") > 0) {
59 std::cout << cmdline_options << std::endl;
60 std::exit(EXIT_SUCCESS);
66 catch (
const po::required_option& e) {
67 std::cerr <<
"Error: " << e.what() << std::endl;
68 std::cerr <<
"Use '-h' to display all valid options." << std::endl;
69 std::exit(EXIT_FAILURE);
71 catch (
const po::invalid_option_value& e) {
72 std::cerr <<
"Error: " << e.what() << std::endl;
73 std::cerr <<
"Use '-h' to display all valid options." << std::endl;
74 std::exit(EXIT_FAILURE);
80 std::stringstream interpreter;
81 interpreter << std::hex << sOption;
88 ss << sOption <<
": Value out of range (bigger than 0xFF) for --sys";
89 throw po::invalid_option_value(ss.str());
void ConvertSysId(const std::string &option)
ProgramOptions(int argc, char *argv[])
Standard constructor with command line arguments.
std::string sFullFilename