Add pagination to detail result

Add version of libraries info to header
This commit is contained in:
2024-04-04 00:14:21 +02:00
parent cf83d1f8f4
commit 3bc51cb7b0
5 changed files with 80 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
#include <iostream>
#include <sys/ioctl.h>
#include <utility>
#include <unistd.h>
#include <argparse/argparse.hpp>
#include "manage/ManageScreen.h"
@@ -7,7 +8,6 @@
void manageArguments(argparse::ArgumentParser& program, int argc, char** argv)
{
program.add_argument("-n", "--number").default_value(0).help("Number of results to show (0 = all)").scan<'i', int>();
program.add_argument("-m", "--model").default_value("any").help("Filter results of the selected model)");
program.add_argument("-s", "--score").default_value("any").help("Filter results of the score name supplied");
program.add_argument("--complete").help("Show only results with all datasets").default_value(false).implicit_value(true);
@@ -15,10 +15,6 @@ void manageArguments(argparse::ArgumentParser& program, int argc, char** argv)
program.add_argument("--compare").help("Compare with best results").default_value(false).implicit_value(true);
try {
program.parse_args(argc, argv);
auto number = program.get<int>("number");
if (number < 0) {
throw std::runtime_error("Number of results must be greater than or equal to 0");
}
auto model = program.get<std::string>("model");
auto score = program.get<std::string>("score");
auto complete = program.get<bool>("complete");
@@ -32,18 +28,16 @@ void manageArguments(argparse::ArgumentParser& program, int argc, char** argv)
}
}
int numRows()
std::pair<int, int> numRowsCols()
{
#ifdef TIOCGSIZE
struct ttysize ts;
ioctl(STDIN_FILENO, TIOCGSIZE, &ts);
// cols = ts.ts_cols;
return ts.ts_lines;
return { ts.ts_lines, ts.ts_cols };
#elif defined(TIOCGWINSZ)
struct winsize ts;
ioctl(STDIN_FILENO, TIOCGWINSZ, &ts);
// cols = ts.ws_col;
return ts.ws_row;
return { ts.ws_row, ts.ws_col };
#endif /* TIOCGSIZE */
}
@@ -51,18 +45,15 @@ int main(int argc, char** argv)
{
auto program = argparse::ArgumentParser("b_manage", { platform_project_version.begin(), platform_project_version.end() });
manageArguments(program, argc, argv);
int number = program.get<int>("number");
std::string model = program.get<std::string>("model");
std::string score = program.get<std::string>("score");
auto complete = program.get<bool>("complete");
auto partial = program.get<bool>("partial");
auto compare = program.get<bool>("compare");
if (number == 0) {
number = std::max(0, numRows() - 6); // 6 is the number of lines used by the menu & header
}
auto [rows, cols] = numRowsCols();
if (complete)
partial = false;
auto manager = platform::ManageScreen(number, model, score, complete, partial, compare);
auto manager = platform::ManageScreen(rows, cols, model, score, complete, partial, compare);
manager.doMenu();
return 0;
}