Add implementation
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@@ -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;
|
||||
|
Reference in New Issue
Block a user