79137792

Date: 2024-10-29 15:06:25
Score: 1
Natty:
Report link

You could write your own parser

namespace po = boost::program_options;

std::pair<std::string, std::string> short_flag_parser(const std::string& s)
{
    // one letter arguments work with single dash
    if (s[0] == '-' && s.size() == 2) {
        return make_pair(s.substr(1), std::string());
    } else {
        return make_pair(std::string(), std::string());
    }
};

int main() {
    desc.add_options()
        ("help, h", "produce help message");
    

    po::variables_map vm;
    po::store(po::command_line_parser(ac, av).options(desc).extra_parser(short_flag_parser).run(), vm);
    po::notify(vm);    

    if (vm.count("help")) {
        std::cout << desc;
        return;
    }
}
Reasons:
  • Blacklisted phrase (1): help me
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Alexander Popov