diff --git a/src/runtime_src/core/tools/xbutil2/OO_Reports.cpp b/src/runtime_src/core/tools/xbutil2/OO_Reports.cpp index 56d1b2b4bd..15ed976249 100644 --- a/src/runtime_src/core/tools/xbutil2/OO_Reports.cpp +++ b/src/runtime_src/core/tools/xbutil2/OO_Reports.cpp @@ -67,7 +67,7 @@ print_preemption_telemetry(const xrt_core::device* device) // ----- C L A S S M E T H O D S ------------------------------------------- OO_Reports::OO_Reports( const std::string &_longName, bool _isHidden ) - : OptionOptions(_longName, _isHidden, "Hidden reports") + : OptionOptions(_longName, _isHidden, "Reports to generate: clocks, preemption") , m_device("") , m_action("") , m_help(false) @@ -75,9 +75,11 @@ OO_Reports::OO_Reports( const std::string &_longName, bool _isHidden ) m_optionsDescription.add_options() ("device,d", boost::program_options::value(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest") ("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command") - ("mode", boost::program_options::value(&m_action)->required(), "Action to perform: clocks, preemption") ; + m_optionsHidden.add_options() + ("mode", boost::program_options::value(&m_action)->implicit_value(""), "Reports to generate: clocks, preemption"); + m_positionalOptions. add("mode", 1 /* max_count */) ; @@ -100,25 +102,17 @@ OO_Reports::execute(const SubCmdOptions& _options) const // Parse sub-command ... po::variables_map vm; + process_arguments(vm, _options); - try { - po::options_description all_options("All Options"); - all_options.add(m_optionsDescription); - po::command_line_parser parser(_options); - XBUtilities::process_arguments(vm, parser, all_options, m_positionalOptions, true); - } catch(boost::program_options::error&) { - if(m_help) { - printHelp(); - throw xrt_core::error(std::errc::operation_canceled); - } - // Exit if neither action or device specified - if(m_action.empty()) { - std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n"); - printHelp(); - throw xrt_core::error(std::errc::operation_canceled); - } + if (m_help) { + printHelp(); + return; + } + if(m_action.empty()) { + std::cerr << boost::format("ERROR: the required argument for option '--report' is missing\n"); + printHelp(); + throw xrt_core::error(std::errc::operation_canceled); } - // Find device of interest std::shared_ptr device; diff --git a/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp b/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp index 9c1d3b4f0d..099a836121 100644 --- a/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp +++ b/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.cpp @@ -35,7 +35,8 @@ namespace po = boost::program_options; SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreliminary, const boost::property_tree::ptree& configurations) : SubCmd("advanced", - "Low level command operations") + "Low level command operations"), + m_device("") { const std::string longDescription = "Low level command operations."; setLongDescription(longDescription); @@ -45,6 +46,7 @@ SubCmdAdvanced::SubCmdAdvanced(bool _isHidden, bool _isDepricated, bool _isPreli setIsPreliminary(_isPreliminary); m_commonOptions.add_options() + ("device,d", boost::program_options::value(&m_device), "The Bus:Device.Function (e.g., 0000:d8:00.0) device of interest") ("help", boost::program_options::bool_switch(&m_help), "Help to use this sub-command") ; @@ -77,17 +79,13 @@ SubCmdAdvanced::execute(const SubCmdOptions& _options) const auto optionOption = checkForSubOption(vm); // No suboption print help - if (!optionOption) { - printHelp(); + if (!optionOption || m_help) { + printHelp(false, "", XBU::get_device_class(m_device, true)); return; } - // 2) Process the top level options - if (m_help) - topOptions.push_back("--help"); - optionOption->setGlobalOptions(getGlobalOptions()); // Execute the option - optionOption->execute(topOptions); + optionOption->execute(_options); } diff --git a/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h b/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h index 870454e667..b34dc60a72 100644 --- a/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h +++ b/src/runtime_src/core/tools/xbutil2/SubCmdAdvanced.h @@ -17,6 +17,7 @@ class SubCmdAdvanced : public SubCmd { private: bool m_help; + std::string m_device; }; #endif