소스 검색

slop now errors properly when a positional argument is supplied

naelstrof 7 년 전
부모
커밋
ab41bb7d3c
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6
    0
      src/main.cpp

+ 6
- 0
src/main.cpp 파일 보기

@@ -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>();