Add implementation
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Define linker flags here, like: -lsqlite3 -lpthread
|
# Define linker flags here, like: -lsqlite3 -lpthread
|
||||||
LDLIBS :=
|
LDLIBS := -lscrequest -lscterm
|
||||||
|
|
||||||
# Dir name becomes product name.
|
# Dir name becomes product name.
|
||||||
PROJ := $(shell basename $$(pwd))
|
PROJ := $(shell basename $$(pwd))
|
||||||
|
15
src/main.cpp
15
src/main.cpp
@@ -2,7 +2,10 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <sstream>
|
||||||
|
#include <regex>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <libscrequest.hpp>
|
||||||
#include "version.hpp"
|
#include "version.hpp"
|
||||||
|
|
||||||
void print_help() {
|
void print_help() {
|
||||||
@@ -48,7 +51,17 @@ int main(int argc, char* argv[]) {
|
|||||||
std::cerr << "gitlabvers: " << ex.what() << '\n';
|
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) {
|
} 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