| 73 | }; |
| 74 | |
| 75 | static CommandLine |
| 76 | ParseCommandLine(int argc, char **argv) |
| 77 | { |
| 78 | CommandLine c; |
| 79 | |
| 80 | OptionParser option_parser(option_defs, argc, argv); |
| 81 | while (auto o = option_parser.Next()) { |
| 82 | switch (static_cast<Option>(o.index)) { |
| 83 | case Option::CONFIG: |
| 84 | c.config_path = o.value; |
| 85 | break; |
| 86 | |
| 87 | case Option::VERBOSE: |
| 88 | c.verbose = true; |
| 89 | break; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | auto args = option_parser.GetRemaining(); |
| 94 | if (args.empty()) |
| 95 | throw std::runtime_error{usage_text}; |
| 96 | |
| 97 | c.command = args.front(); |
| 98 | c.args = args.subspan(1); |
| 99 | return c; |
| 100 | } |
| 101 | |
| 102 | class GlobalInit { |
| 103 | const ConfigData config; |