Add implementation

This commit is contained in:
2025-01-06 09:32:13 +01:00
parent fa72b7db0a
commit 563638d166
2 changed files with 15 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
# Define linker flags here, like: -lsqlite3 -lpthread
LDLIBS :=
LDLIBS := -lscrequest -lscterm
# Dir name becomes product name.
PROJ := $(shell basename $$(pwd))

View File

@@ -2,7 +2,10 @@
#include <cstdlib>
#include <string>
#include <stdexcept>
#include <sstream>
#include <regex>
#include <getopt.h>
#include <libscrequest.hpp>
#include "version.hpp"
void print_help() {
@@ -48,7 +51,17 @@ int main(int argc, char* argv[]) {
std::cerr << "gitlabvers: " << ex.what() << '\n';
}
}
std::cout << "hello, gitlabvers\n";
sc::requester req;
std::istringstream text {req.get("https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/CHANGELOG.md")};
std::string line;
for (size_t i = 0; i < 5; ++i) {
std::getline(text, line);
}
std::regex pat {R"(\d+\.\d+\.\d+)"};
std::smatch match;
if (std::regex_search(line, match, pat)) {
std::cout << match[0] << '\n';
}
} catch (const std::exception& ex) {
std::cerr << "gitlabvers: " << ex.what() << '\n';
return EXIT_FAILURE;