fix: crash on --help arg
This commit is contained in:
parent
1e3d332002
commit
45f328cd80
1 changed files with 7 additions and 2 deletions
|
|
@ -187,13 +187,18 @@ void App::initApp(int argc, const char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string configFilename;
|
std::string configFilename;
|
||||||
CLI::App cliApp{kAppDescription, kAppName};
|
CLI::App cliApp{kAppDescription};
|
||||||
cliApp.add_option("--config-toml", configFilename, "Use TOML configuration file");
|
cliApp.add_option("--config-toml", configFilename, "Use TOML configuration file");
|
||||||
|
|
||||||
// Allow legacy args.
|
// Allow legacy args.
|
||||||
cliApp.allow_extras();
|
cliApp.allow_extras();
|
||||||
|
|
||||||
cliApp.parse(argc, argv);
|
// Having the help argument crashes without try / catch around it
|
||||||
|
try {
|
||||||
|
cliApp.parse(argc, argv);
|
||||||
|
} catch (const CLI::Error &e) {
|
||||||
|
cliApp.exit(e);
|
||||||
|
}
|
||||||
|
|
||||||
if (!configFilename.empty()) {
|
if (!configFilename.empty()) {
|
||||||
Config config(configFilename, configSection());
|
Config config(configFilename, configSection());
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue