Reverse order of lines when using -a option

Now the most recent come at the end, which is more convenient when
output is done to a terminal.
This commit is contained in:
2025-05-15 21:38:51 +02:00
parent 56309c5e8a
commit c47e03c87c

View File

@@ -3,6 +3,8 @@
#include <string>
#include <stdexcept>
#include <regex>
#include <sstream>
#include <vector>
#include <getopt.h>
#include <libscrequest.hpp>
#include "version.hpp"
@@ -60,11 +62,17 @@ int main(int argc, char* argv[]) {
std::regex pat {R"(^##\s+(\d+\.\d+\.\d+)\s+\((\d+-\d+-\d+))", std::regex::multiline};
std::sregex_iterator beg {text.begin(), text.end(), pat};
std::sregex_iterator end {};
std::vector<std::string> lines;
for (std::sregex_iterator i = beg; i != end; ++i) {
std::smatch match {*i};
std::cout << match[1] << " [" << match[2] << "]\n";
std::ostringstream oss;
oss << match[1] << " [" << match[2] << "]\n";
lines.insert(lines.begin(), oss.str());
if (!all) break;
}
for (const std::string& line : lines) {
std::cout << line;
}
} catch (const std::exception& ex) {
std::cerr << "gitlabvers: " << ex.what() << '\n';
return EXIT_FAILURE;