| 39 | { |
| 40 | |
| 41 | bool SubcommandKernel::doSwitches(const StringList& cmdArgs, ProgramArgs& args) |
| 42 | { |
| 43 | StringList stringArgs = extractStageOptions(cmdArgs); |
| 44 | |
| 45 | try |
| 46 | { |
| 47 | bool help; |
| 48 | |
| 49 | // parseSimple allows us to scan for the help option without |
| 50 | // raising exception about missing arguments and so on. |
| 51 | // It also removes consumed args from the arg list, so parse a copy |
| 52 | // that will be ignored by parse() below. |
| 53 | // Also search for a subcommand. |
| 54 | ProgramArgs hargs; |
| 55 | const StringList& subs = subcommands(); |
| 56 | assert(subs.size()); |
| 57 | hargs.add("help,h", "Print help message", help); |
| 58 | hargs.add("subcommand", "Subcommand for application", m_subcommand). |
| 59 | setPositional(); |
| 60 | hargs.parseSimple(stringArgs); |
| 61 | if (help) |
| 62 | return false; |
| 63 | |
| 64 | if (m_subcommand.empty()) |
| 65 | throw pdal_error(getName() + ": no subcommand found."); |
| 66 | if (!Utils::contains(subs, m_subcommand)) |
| 67 | throw pdal_error(getName() + ": invalid subcommand '" + |
| 68 | m_subcommand + "'."); |
| 69 | |
| 70 | addBasicSwitches(args); |
| 71 | addSubSwitches(args, m_subcommand); |
| 72 | args.parse(stringArgs); |
| 73 | } |
| 74 | catch (arg_error& e) |
| 75 | { |
| 76 | throw pdal_error(getName() + ": " + e.what()); |
| 77 | } |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | void SubcommandKernel::outputHelp() |
nothing calls this directly
no test coverage detected