boost::program_options - parsing multiple command line arguments where some are strings including spaces and characters
I fixed it using a native Windows function which handles command line arguments differently. See CommandLineToArgvW for details. Before passing it to processCommands(), I am modifying my argv[] and argc using the method mentioned above. Thank you Bart van Ingen Schenau for your comment.
#ifdef _WIN32 argv = CommandLineToArgvW(GetCommandLineW(), &argc); if (NULL == argv) { std::wcout << L"CommandLineToArgvw failed" << std::endl; return -1; }#endif
You should be able to achieve this with positional options
:
positional_options_description pos_desc;pos_desc.add("create", 10); // Force a max of 10.
Then when you parse the command line add this pos_desc
:
using namespace boost::program_options;command_line_parser parser{argc, argv};parser.options(desc).positional(pos_desc);store(parser.run(), vm);