| 49 | }; |
| 50 | |
| 51 | static CommandLine |
| 52 | ParseCommandLine(int argc, char **argv) |
| 53 | { |
| 54 | CommandLine c; |
| 55 | |
| 56 | OptionParser option_parser(option_defs, argc, argv); |
| 57 | while (auto o = option_parser.Next()) { |
| 58 | switch (Option(o.index)) { |
| 59 | case OPTION_CONFIG: |
| 60 | c.config_path = o.value; |
| 61 | break; |
| 62 | |
| 63 | case OPTION_VERBOSE: |
| 64 | c.verbose = true; |
| 65 | break; |
| 66 | |
| 67 | case OPTION_SEEK: |
| 68 | c.seek_where = SongTime::FromS(strtod(o.value, nullptr)); |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | auto args = option_parser.GetRemaining(); |
| 74 | if (args.size() != 2) |
| 75 | throw std::runtime_error("Usage: run_decoder [--verbose] [--config=FILE] [--seek=POS] DECODER URI"); |
| 76 | |
| 77 | c.decoder = args[0]; |
| 78 | c.uri = args[1]; |
| 79 | return c; |
| 80 | } |
| 81 | |
| 82 | class GlobalInit { |
| 83 | const ConfigData config; |