Explorar el Código

slop now errors properly when a positional argument is supplied

naelstrof hace 7 años
padre
commit
ab41bb7d3c
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6
    0
      src/main.cpp

+ 6
- 0
src/main.cpp Ver fichero

242
     ("q,quiet", "Disable any unnecessary cerr output. Any warnings or info simply won't print.")
242
     ("q,quiet", "Disable any unnecessary cerr output. Any warnings or info simply won't print.")
243
     ("k,nokeyboard", "Disables the ability to cancel selections with the keyboard.")
243
     ("k,nokeyboard", "Disables the ability to cancel selections with the keyboard.")
244
     ("o,noopengl", "Disables graphics hardware acceleration.")
244
     ("o,noopengl", "Disables graphics hardware acceleration.")
245
+    ("positional", "Positional parameters", cxxopts::value<std::vector<std::string>>())
245
     ;
246
     ;
247
+    options.parse_positional("positional");
246
     options.parse(argc, argv);
248
     options.parse(argc, argv);
247
     // Options just validates all of our input from argv
249
     // Options just validates all of our input from argv
248
     bool quiet = false;
250
     bool quiet = false;
249
     if ( options.count( "quiet" ) > 0 ) {
251
     if ( options.count( "quiet" ) > 0 ) {
250
         quiet = options["quiet"].as<bool>();
252
         quiet = options["quiet"].as<bool>();
251
     }
253
     }
254
+    auto& positional = options["positional"].as<std::vector<std::string>>();
255
+    if ( positional.size() > 0 ) {
256
+        throw new std::invalid_argument("Unexpected positional argument: " + positional[0]);
257
+    }
252
     bool help = false;
258
     bool help = false;
253
     if ( options.count( "help" ) > 0 ) {
259
     if ( options.count( "help" ) > 0 ) {
254
         help = options["help"].as<bool>();
260
         help = options["help"].as<bool>();