void print_help()

in configuration/src/config.cpp [9:44]


void print_help( const struct option* long_options,
                 const std::map<std::string, std::string>& options_descriptions )
{
    std::cout << "Usage: " << std::endl;
    std::cout << "Runtime Environment Variables:" << std::endl; 
    std::cout << "CF_CRED_SPEC_FILE=<credential spec file>:<optional lease_id>" << std::endl; 
    std::cout << "\t<credential spec file>\tSet to a path of a json credential file." << std::endl; 
    std::cout << "\t<optional lease_id>\tUse an optional colon followed by a lease identifier (Default: " 
              << DEFAULT_CRED_FILE_LEASE_ID << ")"  << std::endl; 
    std::cout << "\nAllowed options" << std::endl;
    size_t max_option_length = 0;
    for ( const struct option* opt = long_options; opt->name != nullptr; ++opt )
    {
        size_t option_length =
            opt->has_arg == required_argument ? strlen( opt->name ) + 5 : strlen( opt->name ) + 2;
        if ( option_length > max_option_length )
        {
            max_option_length = option_length;
        }
    }
    for ( const struct option* opt = long_options; opt->name != nullptr; ++opt )
    {
        std::string opt_string = std::string( "--" ) + opt->name;
        std::string description;
        if ( options_descriptions.count( opt->name ) > 0 )
        {
            description = options_descriptions.at( opt->name );
        }
        else
        {
            description = opt->name;
        }
        std::cout << "  " << std::left << std::setw( max_option_length ) << opt_string << "\t"
                  << description << std::endl;
    }
}