Kaynağa Gözat

slop now errors properly when a positional argument is supplied

naelstrof 7 yıl önce
ebeveyn
işleme
ab41bb7d3c
1 değiştirilmiş dosya ile 6 ekleme ve 0 silme
  1. 6
    0
      src/main.cpp

+ 6
- 0
src/main.cpp Dosyayı Görüntüle

@@ -242,13 +242,19 @@ int app( int argc, char** argv ) {
242 242
     ("q,quiet", "Disable any unnecessary cerr output. Any warnings or info simply won't print.")
243 243
     ("k,nokeyboard", "Disables the ability to cancel selections with the keyboard.")
244 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 248
     options.parse(argc, argv);
247 249
     // Options just validates all of our input from argv
248 250
     bool quiet = false;
249 251
     if ( options.count( "quiet" ) > 0 ) {
250 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 258
     bool help = false;
253 259
     if ( options.count( "help" ) > 0 ) {
254 260
         help = options["help"].as<bool>();