26 constexpr int OPTION_WIDTH = 26;
29 std::cout <<
wrapped(s, 0) <<
"\n";
32 if (command_options) {
33 std::vector<const CliOption*> vector_arguments, vector_options;
36 vector_arguments.push_back(opt);
38 vector_options.push_back(opt);
42 std::cout << BOLD(UNDERLINE(
"Usage:")) <<
" "
45 << (!vector_options.empty() ?
" [OPTIONS]" :
"")
46 << (!vector_arguments.empty() ?
" [--] [ARGUMENTS]" :
"")
49 if (!vector_arguments.empty()) {
50 std::cout << BOLD(UNDERLINE(
"Arguments:")) <<
"\n";
52 for (
const auto& item : vector_arguments) {
53 std::string opts_str =
" ";
57 std::cout << std::left << std::setw(OPTION_WIDTH) << opts_str;
58 if (item->description !=
nullptr) {
59 std::cout <<
wrapped(item->description, OPTION_WIDTH);
65 if (!vector_options.empty()) {
66 std::sort(vector_options.begin(), vector_options.end(), [](
const CliOption* a,
const CliOption* b) {
67 return std::string_view(a->long_name) < std::string_view(b->long_name);
70 std::cout << BOLD(UNDERLINE(
"Options:")) <<
"\n";
72 for (
const auto& item : vector_options) {
73 std::string opts_str =
" ";
74 if (item->short_name != 0)
75 opts_str +=
"-" + std::string(1,
static_cast<char>(item->short_name));
76 if (!opts_str.empty() && item->long_name && item->short_name)
78 if (!item->short_name)
81 opts_str +=
"--" + std::string(item->long_name);
82 opts_str = BOLD(opts_str);
87 std::cout << std::left << std::setw(OPTION_WIDTH + 8) << opts_str;
88 if (item->description !=
nullptr) {
89 std::cout <<
wrapped(item->description, OPTION_WIDTH);