mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 21:40:15 +08:00
cmake::Workflow: Refactor to use enum class argument
This commit is contained in:
@@ -3732,7 +3732,8 @@ std::function<int()> cmake::BuildWorkflowStep(
|
||||
}
|
||||
#endif
|
||||
|
||||
int cmake::Workflow(const std::string& presetName, bool listPresets)
|
||||
int cmake::Workflow(const std::string& presetName,
|
||||
WorkflowListPresets listPresets)
|
||||
{
|
||||
#ifndef CMAKE_BOOTSTRAP
|
||||
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
|
||||
@@ -3747,7 +3748,7 @@ int cmake::Workflow(const std::string& presetName, bool listPresets)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (listPresets) {
|
||||
if (listPresets == WorkflowListPresets::Yes) {
|
||||
settingsFile.PrintWorkflowPresetList();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -602,7 +602,12 @@ public:
|
||||
bool Open(const std::string& dir, bool dryRun);
|
||||
|
||||
//! run the --workflow option
|
||||
int Workflow(const std::string& presetName, bool listPresets);
|
||||
enum class WorkflowListPresets
|
||||
{
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
int Workflow(const std::string& presetName, WorkflowListPresets listPresets);
|
||||
|
||||
void UnwatchUnusedCli(const std::string& var);
|
||||
void WatchUnusedCli(const std::string& var);
|
||||
|
@@ -917,8 +917,9 @@ int do_workflow(int ac, char const* const* av)
|
||||
std::cerr << "This cmake does not support --workflow\n";
|
||||
return -1;
|
||||
#else
|
||||
using WorkflowListPresets = cmake::WorkflowListPresets;
|
||||
std::string presetName;
|
||||
bool listPresets = false;
|
||||
auto listPresets = WorkflowListPresets::No;
|
||||
|
||||
using CommandArgument =
|
||||
cmCommandLineArgument<bool(std::string const& value)>;
|
||||
@@ -927,7 +928,10 @@ int do_workflow(int ac, char const* const* av)
|
||||
CommandArgument{ "--preset", CommandArgument::Values::One,
|
||||
CommandArgument::setToValue(presetName) },
|
||||
CommandArgument{ "--list-presets", CommandArgument::Values::Zero,
|
||||
CommandArgument::setToTrue(listPresets) }
|
||||
[&listPresets](const std::string&) -> bool {
|
||||
listPresets = WorkflowListPresets::Yes;
|
||||
return true;
|
||||
} },
|
||||
};
|
||||
|
||||
std::vector<std::string> inputArgs;
|
||||
@@ -950,14 +954,14 @@ int do_workflow(int ac, char const* const* av)
|
||||
if (!(matched && parsed)) {
|
||||
if (!matched) {
|
||||
presetName.clear();
|
||||
listPresets = false;
|
||||
listPresets = WorkflowListPresets::No;
|
||||
std::cerr << "Unknown argument " << arg << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (presetName.empty() && !listPresets) {
|
||||
if (presetName.empty() && listPresets == WorkflowListPresets::No) {
|
||||
/* clang-format off */
|
||||
std::cerr <<
|
||||
"Usage: cmake --workflow [options]\n"
|
||||
|
Reference in New Issue
Block a user