void CmdlineParser::print_usage()

in src/controller/cmdline_parser.h [264:308]


void CmdlineParser<CLI>::print_usage(std::ostream& out, const char* name)
{
    out << "Usage: " << name << " [OPTIONS]..." << std::endl;

    for(const Opt& o : CLI::options)
    {
        std::string s_opt;
        std::string l_opt;
        std::string text;

        if(o.short_opt) // print out short key
        {
            char tmp[]{'-', o.short_opt, ' ', '\0'};
            if(o.long_opt) tmp[2] = ',';
            s_opt                 = std::string{"   "} + tmp; //indentation
        }
        if(o.long_opt) // print out long key
        {
            l_opt = std::string{" --"} + o.long_opt;

            if(o.value_pattern)
            {
                l_opt += '=';
                l_opt += o.value_pattern;
            }
        }
        if(o.deflt) // has default value?
        {
            text = std::string{"(default:"} + o.deflt + ") ";
        }
        else
        {
            text = "(required) ";
        }

        if(o.description)
        {
            text += o.description;
        }

        out << std::setw(6) << s_opt
            << std::setiosflags(std::ios::left) << std::setw(35) << l_opt
            << text << std::endl;
    }
}