opt_parser.cpp File Reference
#include "opt_parser.h"
+ Include dependency graph for opt_parser.cpp:

Go to the source code of this file.

Functions

cxxopts::ParseResult parse (int argc, char *argv[])
 

Function Documentation

◆ parse()

cxxopts::ParseResult parse ( int  argc,
char *  argv[] 
)

Definition at line 18 of file opt_parser.cpp.

18  {
19  try {
20  cxxopts::Options options(
21  argv[0], "Structure calculations for molecular simulations");
22  options.positional_help("[optional args]").show_positional_help();
23  options.allow_unrecognised_options().add_options()(
24  "c,config", "Yaml Config",
25  cxxopts::value<std::string>()->default_value("conf.yml"))
26 
27  ("h,help", "Print help");
28  auto result = options.parse(argc, argv);
29 
30  if (result.count("help")) {
31  std::cout << options.help({"", "Group"}) << std::endl;
32  exit(0);
33  }
34  // No options
35  if (result.arguments().size() == 0) {
36  std::cout << "DO error handling" << std::endl;
37  }
38  return result;
39  } catch (const cxxopts::OptionException &e) {
40  std::cout << "error parsing options: " << e.what() << std::endl;
41  exit(1);
42  }
43 }
T endl(T... args)
T exit(T... args)