Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
cmd.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 CERN
2// SPDX-License-Identifier: GPL-3.0-or-later
3
4#ifndef CMD_HPP_
5#define CMD_HPP_
6
7#include <CLI/CLI.hpp>
8#include <vector>
9#include <boost/algorithm/string.hpp>
10
11#define COLUMN_WIDTH 35
12
13namespace adaptyst {
18 class PrettyFormatter : public CLI::Formatter {
19 public:
21 this->column_width(COLUMN_WIDTH);
22 }
23
24 std::string make_option_desc(const CLI::Option *opt) const override {
25 std::vector<std::string> parts;
26 boost::split(parts, opt->get_description(), boost::is_any_of(" "));
27
28 int characters_printed_in_line = 0;
29 std::string result = "";
30
31 bool finish_with_new_line = false;
32
33 for (int i = 0; i < parts.size(); i++) {
34 std::string to_print = parts[i];
35
36 if (i < parts.size() - 1) {
37 to_print += " ";
38 }
39
40 if (characters_printed_in_line > 0 &&
41 characters_printed_in_line + to_print.length() >= 80 - COLUMN_WIDTH) {
42 result += "\n";
43 characters_printed_in_line = 0;
44 finish_with_new_line = true;
45 }
46
47 result += to_print;
48 characters_printed_in_line += to_print.length();
49 }
50
51 return result + (finish_with_new_line ? "\n" : "");
52 }
53 };
54};
55
56#endif
PrettyFormatter()
Definition cmd.hpp:20
std::string make_option_desc(const CLI::Option *opt) const override
Definition cmd.hpp:24
#define COLUMN_WIDTH
Definition cmd.hpp:11
Definition output.hpp:12