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:
10
src/main.cpp
10
src/main.cpp
@@ -3,6 +3,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
|
#include <vector>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <libscrequest.hpp>
|
#include <libscrequest.hpp>
|
||||||
#include "version.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::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 beg {text.begin(), text.end(), pat};
|
||||||
std::sregex_iterator end {};
|
std::sregex_iterator end {};
|
||||||
|
std::vector<std::string> lines;
|
||||||
for (std::sregex_iterator i = beg; i != end; ++i) {
|
for (std::sregex_iterator i = beg; i != end; ++i) {
|
||||||
std::smatch match {*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;
|
if (!all) break;
|
||||||
}
|
}
|
||||||
|
for (const std::string& line : lines) {
|
||||||
|
std::cout << line;
|
||||||
|
}
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
std::cerr << "gitlabvers: " << ex.what() << '\n';
|
std::cerr << "gitlabvers: " << ex.what() << '\n';
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
Reference in New Issue
Block a user