Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The help flag didn't get processed when a config file was required. #606

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

phlptp
Copy link
Collaborator

@phlptp phlptp commented Jun 18, 2021

This fixes issue #553

@phlptp phlptp force-pushed the help_config_required branch from a16e81a to 47eaa2a Compare June 18, 2021 18:06
Comment on lines +2251 to +2271
CLI::FileError fe("ne");
bool caught_error{false};
try {
// the config file might generate a FileError but that should not be processed until later in the process
// to allow for help, version and other errors to generate first.
_process_config_file();
// process env shouldn't throw but no reason to process it if config generated an error
_process_env();
} catch(const CLI::FileError &fe2) {
fe = fe2;
caught_error = true;
}
// callbacks and help_flags can generate exceptions which should take priority over the config file error if one
// exists
_process_callbacks();
_process_help_flags();

if(caught_error) {
throw CLI::FileError(std::move(fe));
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to use a unique_ptr here (really need an optional), but this should get refactored by the error handling update whenever that comes, so I think this is fine.

@henryiii henryiii merged commit f27822d into CLIUtils:master Jun 21, 2021
@henryiii henryiii deleted the help_config_required branch June 21, 2021 16:13
@github-actions github-actions bot added needs changelog Hasn't been added to the changelog yet needs README Needs to be mentioned in the README labels Jun 21, 2021
@henryiii henryiii added this to the v2.0 milestone Jun 24, 2021
@henryiii henryiii removed needs README Needs to be mentioned in the README needs changelog Hasn't been added to the changelog yet labels Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants