Skip to content

Proper way to get path to the config file that was parsed #236

Closed
@pwm1234

Description

@pwm1234

What is the right way to get the path to the config file that was parsed? For debugging purposes, I want to log the path to the config file that was loaded. Since the default path could have been overridden during argument parsing, I need the Option returned by the app->get_config_ptr() call to tell me. At least this is how I have done it:

CLI::Option* config = app.get_config_ptr();
std::vector<std::string> results = config->results();
std::string config_file = config->get_defaultval();
if (results.size() > 0)
{
    config_file = results[0];
}

Is there a better way? If not, should there be a better way? If this is not obvious, should this be added to the documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions