cmCMakePresetsGraph: use std::setw instead of for-loop + one space at time

This commit is contained in:
Alex Turbov committed 2026-04-11 21:28:20 +04:00
1 parent 43a18bfaee
commit 0bf8df384c
1 file changed
+8 -7
+8 -7
View File
@@ -4,8 +4,8 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <utility>
@@ -1365,15 +1365,16 @@ void cmCMakePresetsGraph::PrintPresets(
auto longestLength = (*longestPresetName)->Name.length();
for (auto const* preset : presets) {
std::cout << " \"" << preset->Name << '"';
auto name = cmStrCat(" \"", preset->Name, '"');
auto const& description = preset->DisplayName;
if (!description.empty()) {
for (std::size_t i = 0; i < longestLength - preset->Name.length(); ++i) {
std::cout << ' ';
}
std::cout << " - " << description;
int const width = static_cast<int>(longestLength + name.length() -
preset->Name.length());
std::cout << std::left << std::setw(width) << name << " - "
<< description << '\n';
} else {
std::cout << name << '\n';
}
std::cout << '\n';
}
}