Parcourir la source

cmake --workflow: print usage and exit on unrecognized argument

Issue: #24073
Kyle Edwards il y a 3 ans
Parent
commit
322193afcd

+ 2 - 0
Source/cmakemain.cxx

@@ -949,6 +949,8 @@ int do_workflow(int ac, char const* const* av)
     }
     if (!(matched && parsed)) {
       if (!matched) {
+        presetName.clear();
+        listPresets = false;
         std::cerr << "Unknown argument " << arg << std::endl;
       }
       break;

+ 1 - 0
Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-result.txt

@@ -0,0 +1 @@
+1

+ 6 - 0
Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stderr.txt

@@ -0,0 +1,6 @@
+^Unknown argument -DINVALID_OPTION
+Usage: cmake --workflow \[options\]
+Options:
+  --preset <preset> = Workflow preset to execute\.
+  --list-presets    = List available workflow presets\.
+  --fresh           = Configure a fresh build tree, removing any existing cache file\.$

+ 1 - 0
Tests/RunCMake/CMakePresetsWorkflow/InvalidOption-stdout.txt

@@ -0,0 +1 @@
+^$

+ 1 - 0
Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake

@@ -77,3 +77,4 @@ unset(CMakeUserPresets_FILE)
 unset(CMakePresets_ASSETS)
 
 run_cmake_workflow_presets(ListPresets --list-presets)
+run_cmake_workflow_presets(InvalidOption -DINVALID_OPTION)