ArmNN
 20.05
CommandLineProcessor.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2019 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
7 
8 #include <boost/program_options.hpp>
9 #include <iostream>
10 
11 namespace armnn
12 {
13 namespace gatordmock
14 {
15 
16 bool CommandLineProcessor::ProcessCommandLine(int argc, char *argv[])
17 {
18  namespace po = boost::program_options;
19  po::options_description desc("Options");
20  try
21  {
22  desc.add_options()
23  ("help,h", "Display help messages")
24  ("file,f", po::value<std::string>(&m_File),
25  "The path to the file that contains instructions for the mock gatord")
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")
29  ("echo,e", po::bool_switch(&m_Echo)->default_value(false),
30  "Echo packets sent and received to stdout. Disabled by default.\n");
31  }
32  catch (const std::exception& e)
33  {
34  std::cerr << "Fatal internal error: [" << e.what() << "]" << std::endl;
35  return false;
36  }
37 
38  po::variables_map vm;
39  try
40  {
41  po::store(po::parse_command_line(argc, argv, desc), vm);
42 
43  if (vm.count("help"))
44  {
45  std::cout << "Simulate a Gatord server to interact with ArmNN external profiling." << std::endl;
46  std::cout << std::endl;
47  std::cout << desc << std::endl;
48  return false;
49  }
50  // Currently the file parameter is mandatory.
51  if (!vm.count("file"))
52  {
53  std::cout << std::endl << "*** Expected --file or -f parameter." << std::endl;
54  std::cout << std::endl;
55  std::cout << desc << std::endl;
56  return false;
57  }
58  po::notify(vm);
59  }
60  catch (const po::error& e)
61  {
62  std::cerr << e.what() << std::endl << std::endl;
63  std::cerr << desc << std::endl;
64  return false;
65  }
66 
67  return true;
68 }
69 
70 } // namespace gatordmock
71 
72 } // namespace armnn
bool ProcessCommandLine(int argc, char *argv[])
Copyright (c) 2020 ARM Limited.