#include "CommandLineProcessor.hpp"
-#include <boost/program_options.hpp>
+#include <cxxopts/cxxopts.hpp>
#include <iostream>
namespace armnn
bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[])
{
- namespace po = boost::program_options;
- po::options_description desc("Options");
+ cxxopts::Options options("GatordMock",
+ "Simulate a Gatord server to interact with ArmNN external profiling.");
+
try
{
- desc.add_options()
- ("help,h", "Display help messages")
- ("file,f", po::value<std::string>(&m_File),
- "The path to the file that contains instructions for the mock gatord")
- ("namespace,n", po::value<std::string>(&m_UdsNamespace)->default_value("gatord_namespace"),
- "The Unix domain socket namespace this server will bind to.\n"
- "This will always be prepended with \\0 to use the abstract namespace")
- ("echo,e", po::bool_switch(&m_Echo)->default_value(false),
- "Echo packets sent and received to stdout. Disabled by default.\n");
+ options.add_options()
+ ("h,help", "Display help messages")
+ ("f,file",
+ "The path to the file that contains instructions for the mock gatord.",
+ cxxopts::value<std::string>(m_File))
+ ("n,namespace",
+ "The Unix domain socket namespace this server will bind to.\n"
+ "This will always be prepended with \\0 to use the abstract namespace",
+ cxxopts::value<std::string>(m_UdsNamespace)->default_value("gatord_namespace"))
+ ("e,echo",
+ "Echo packets sent and received to stdout. Disabled by default. "
+ "Default value = false.",
+ cxxopts::value<bool>(m_Echo)->default_value("false"));
}
catch (const std::exception& e)
{
return false;
}
- po::variables_map vm;
try
{
- po::store(po::parse_command_line(argc, argv, desc), vm);
+ auto result = options.parse(argc, argv);
- if (vm.count("help"))
+ if (result.count("help"))
{
- std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl;
- std::cout << std::endl;
- std::cout << desc << std::endl;
+ std::cout << options.help() << std::endl;
return false;
}
+
// Currently the file parameter is mandatory.
- if (!vm.count("file"))
+ if (!result.count("file"))
{
- std::cout << std::endl << "*** Expected --file or -f parameter." << std::endl;
- std::cout << std::endl;
- std::cout << desc << std::endl;
+ std::cout << "-f/--file parameter is mandatory." << std::endl;
return false;
}
- po::notify(vm);
+
+ // Sets bool value correctly.
+ if (result.count("echo"))
+ {
+ m_Echo = true;
+ }
}
- catch (const po::error& e)
+ catch (const cxxopts::OptionException& e)
{
- std::cerr << e.what() << std::endl << std::endl;
- std::cerr << desc << std::endl;
+ std::cerr << e.what() << std::endl;
return false;
}