Colm Donelan | 366023f | 2019-09-05 10:03:56 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2019 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "CommandLineProcessor.hpp" |
| 7 | |
| 8 | #include <boost/program_options.hpp> |
| 9 | |
| 10 | #include <iostream> |
| 11 | |
| 12 | namespace armnn |
| 13 | { |
| 14 | namespace gatordmock |
| 15 | { |
| 16 | |
| 17 | bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[]) |
| 18 | { |
| 19 | namespace po = boost::program_options; |
| 20 | |
| 21 | po::options_description desc("Options"); |
| 22 | try |
| 23 | { |
Colm Donelan | a85e215 | 2019-09-09 11:59:08 +0100 | [diff] [blame] | 24 | desc.add_options() |
| 25 | ("help,h", "Display help messages") |
| 26 | ("namespace,n", po::value<std::string>(&m_UdsNamespace)->default_value("gatord_namespace"), |
| 27 | "The Unix domain socket namespace this server will bind to.\n" |
| 28 | "This will always be prepended with \\0 to use the abstract namespace"); |
Colm Donelan | 366023f | 2019-09-05 10:03:56 +0100 | [diff] [blame] | 29 | } |
| 30 | catch (const std::exception& e) |
| 31 | { |
| 32 | std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl; |
| 33 | return false; |
| 34 | } |
| 35 | |
| 36 | po::variables_map vm; |
| 37 | try |
| 38 | { |
| 39 | po::store(po::parse_command_line(argc, argv, desc), vm); |
| 40 | |
Colm Donelan | a85e215 | 2019-09-09 11:59:08 +0100 | [diff] [blame] | 41 | if (vm.count("help")) |
Colm Donelan | 366023f | 2019-09-05 10:03:56 +0100 | [diff] [blame] | 42 | { |
| 43 | std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl; |
| 44 | std::cout << std::endl; |
| 45 | std::cout << desc << std::endl; |
| 46 | return false; |
| 47 | } |
| 48 | |
| 49 | po::notify(vm); |
| 50 | } |
| 51 | catch (const po::error& e) |
| 52 | { |
| 53 | std::cerr << e.what() << std::endl << std::endl; |
| 54 | std::cerr << desc << std::endl; |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | } // namespace gatordmock |
| 62 | |
| 63 | } // namespace armnn |