MCPcopy Create free account
hub / github.com/PDAL/PDAL / doSwitches

Method doSwitches

pdal/SubcommandKernel.cpp:41–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39{
40
41bool 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
82void SubcommandKernel::outputHelp()

Callers

nothing calls this directly

Calls 9

addSubSwitchesFunction · 0.85
parseSimpleMethod · 0.80
getNameFunction · 0.50
containsFunction · 0.50
sizeMethod · 0.45
addMethod · 0.45
emptyMethod · 0.45
parseMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected